-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_4_parametrized_constructor.java
More file actions
40 lines (39 loc) · 1.1 KB
/
Copy path_4_parametrized_constructor.java
File metadata and controls
40 lines (39 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//public class _4_parametrized_constructor {
// int x,y;
// _4_parametrized_constructor(int a, int b) //parameterized
// {
// x=a; y=b;
// }
// void show() {
// System.out.println(x + " " + y);
// }
//}
//class B {
// public static void main(String[] args) {
// _4_parametrized_constructor r = new _4_parametrized_constructor(100,200);
// r.show();
// }
//}
public class _4_parametrized_constructor {
int x,y;
_4_parametrized_constructor(int a, int b) //parameterized
{
x=a; y=b;
}
// we can make more parameterized constructor like this
// but datatype will be change
_4_parametrized_constructor(int a, String b) //parameterized
{
System.out.println(a+" "+b);
}
void show() {
System.out.println(x + " " + y);
}
}
class four {
public static void main(String[] args) {
_4_parametrized_constructor r = new _4_parametrized_constructor(100,200);
_4_parametrized_constructor ref = new _4_parametrized_constructor(10,"Aagman");
r.show();
}
}