0
What's wrong in this code
class Animal{ int legs; String type; static void sound(){ system.out.println("Hmm"); } class Dog extends Animal{ Dog(int legs,String type){ this.legs=legs; this.type=type; static void sound(){ system.out.print("Va"); } static void description(){ System.out.print("i have" +legs ); } } } } public class Program { public static void main(String[] args) { Dog d =new Dog(4,"samuski"); d.description(); } }
5 Respostas
+ 4
You have a couple of errors including misplaced curly braces and system must start with a capital 'S'. Also I made one of the instance variable static and the reason is mentioned alongside.
https://code.sololearn.com/cenH8oQ8vR7G/?ref=app
0
K
0
Tysm