Skip to content

Commit 383a61f

Browse files
Inheritance
1 parent 3fdcd04 commit 383a61f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

12.Inheritance/StaticInParent/program2.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ class Parent2{
44
static {
55
System.out.println("In parent static block");
66
}
7+
8+
{
9+
System.out.println("In Parent instance block");
10+
}
711
}
812

913
class child2 extends Parent2 {
@@ -12,11 +16,15 @@ class child2 extends Parent2 {
1216
System.out.println("In child static block");
1317
}
1418

19+
{
20+
System.out.println("In Child instance block");
21+
}
22+
1523
}
1624

1725
class client2{
1826
public static void main(String[] args) {
1927

20-
child2 obj = new child2();
28+
Parent2 obj = new child2();
2129
}
2230
}

12.Inheritance/StaticInParent/program3.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class Parent3{
55
static int x = 10;
66

77
static {
8+
9+
// static int x =10;
810
System.out.println("In parent static block");
911
}
1012

0 commit comments

Comments
 (0)