forked from akash-coded/C133-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThisConstructorCall.java
More file actions
31 lines (26 loc) · 831 Bytes
/
ThisConstructorCall.java
File metadata and controls
31 lines (26 loc) · 831 Bytes
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
class SuperAndThis {
SuperAndThis() {
System.out.println("Welcome from parent class");
}
SuperAndThis(String msg) {
System.out.print("Parameterized constructor of parent: ");
System.out.println(msg.length());
}
}
class ThisConstructorCall extends SuperAndThis {
ThisConstructorCall() {
super();
System.out.println("Welcome from non-parameterized constructor");
}
ThisConstructorCall(String msg) {
this();
System.out.println("Parameterized constructor: " + msg);
}
ThisConstructorCall(String msg1, String msg2) {
this(msg1);
System.out.println("Parameterized constructor 2: " + msg2);
}
public static void main(String[] args) {
ThisConstructorCall obj = new ThisConstructorCall("Akash", "Das");
}
}