File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ class SuperA {
2
+ void method1 (){
3
+ System .out .println ("SuperA" );
4
+ }
5
+ }
6
+ class SubB extends SuperA {
7
+ void method1 (){
8
+ super .method1 ();
9
+ System .out .println ("SubB" );
10
+ }
11
+ }
12
+ public class Main {
13
+ public static void main (String [] args ){
14
+ SubB sb =new SubB ();
15
+ sb .method1 ();
16
+
17
+
18
+ }
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ class SuperA {
2
+ SuperA (){
3
+ System .out .println ("default constructor of super class" );
4
+ }
5
+ SuperA (int x ){
6
+ System .out .println ("parameterized constructor of super class with value: " +x );
7
+ }
8
+ }
9
+
10
+ class SubB extends SuperA {
11
+ SubB (int x ){
12
+ super (145 );//comment this line to see diff output
13
+ System .out .println ("parameterized constructor of sub class with value: " +x );
14
+
15
+ }
16
+ }
17
+ public class Main {
18
+ public static void main (String [] args ){
19
+ SubB sb =new SubB (123 );
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments