0
What is wrong with the code
class Parentclass { Parentclass(){ System.out.println("no-arg constructor of parent class"); } Parentclass(String str){ System.out.println("parameterized constructor of parent class"); } } class Subclass extends Parentclass { Subclass(){ super("Hahaha"); System.out.println("Constructor of child class"); } void display(){ System.out.println("Hello"); } public static void main(String args[]){ Subclass obj= new Subclass(); obj.display(); } }
1 Antwort
0
it seems on SoloLearn is problem with the word 'class' in name of sub class.
Rename 'Subclass' to eg 'Subclas' if you run it on SL
In standard java terminal your code works properly.