0
What the hell iS wrong with my Super keyword programm ?
Calling superclass method through keyword super . https://code.sololearn.com/cyfLJxb5UVzD/?ref=app
8 Antworten
+ 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");
}
}
+ 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.
0
https://code.sololearn.com/cdR71c24k4DJ/?ref=app
https://www.javatpoint.com/super-keyword#:~:text=The%20super%20keyword%20in%20Java,referred%20by%20super%20reference%20variable.
0
You cant call super.alpha() in class Program because Program dosent extend class A and therefore is not a super class of Program.
0
Now have a lOok
0
class Program now extends Class A
0
Still it's the same D_Stark
0
Pankaj What is your expected output..??