0

What the hell iS wrong with my Super keyword programm ?

Calling superclass method through keyword super . https://code.sololearn.com/cyfLJxb5UVzD/?ref=app

8th Dec 2020, 7:47 AM
Pankaj
Pankaj - avatar
8 Réponses
+ 1
Just_ Luvvv behind the scenes the b class looks like this the moment you create an object, super class constructor is called first as B cannot exist without A being constructed first class B extends A { public B(){ super(); // but you dont see this System.out.println(" Csnstrctr B"); } }
8th Dec 2020, 5:59 PM
D_Stark
D_Stark - avatar
+ 1
you are better off not calling super in the child class since you are not call the superclass' contructor.Again you are extending A in program hence program has access to all methods defined in A thus just calling alpha would be better.
10th Dec 2020, 6:26 AM
John
John - avatar
0
You cant call super.alpha() in class Program because Program dosent extend class A and therefore is not a super class of Program.
8th Dec 2020, 9:16 AM
D_Stark
D_Stark - avatar
0
Now have a lOok
8th Dec 2020, 10:26 AM
Pankaj
Pankaj - avatar
0
class Program now extends Class A
8th Dec 2020, 10:27 AM
Pankaj
Pankaj - avatar
0
Still it's the same D_Stark
8th Dec 2020, 10:27 AM
Pankaj
Pankaj - avatar
0
Pankaj What is your expected output..??
9th Dec 2020, 3:04 PM
❤☆Nani☆❤
❤☆Nani☆❤ - avatar