File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
12.Inheritance/StaticInParent Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ class Parent2{
4
4
static {
5
5
System .out .println ("In parent static block" );
6
6
}
7
+
8
+ {
9
+ System .out .println ("In Parent instance block" );
10
+ }
7
11
}
8
12
9
13
class child2 extends Parent2 {
@@ -12,11 +16,15 @@ class child2 extends Parent2 {
12
16
System .out .println ("In child static block" );
13
17
}
14
18
19
+ {
20
+ System .out .println ("In Child instance block" );
21
+ }
22
+
15
23
}
16
24
17
25
class client2 {
18
26
public static void main (String [] args ) {
19
27
20
- child2 obj = new child2 ();
28
+ Parent2 obj = new child2 ();
21
29
}
22
30
}
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ class Parent3{
5
5
static int x = 10 ;
6
6
7
7
static {
8
+
9
+ // static int x =10;
8
10
System .out .println ("In parent static block" );
9
11
}
10
12
You can’t perform that action at this time.
0 commit comments