5 Réponses
+ 5
You missed two closing braces for class Person and Teacher. '@override' is supposed to be '@Override'. In main, there is no attribute 'quality' for object of type Teacher. Please refer to the fix I provided:
public class Person{
String name;
int age;
void display(){
System.out.println("Name is: " +name);
System.out.println("Age is : " +age);
}
}
public class Teacher extends Person {
String qualification;
@Override
void display(){
System.out.println("Name is: " +name) ;
System.out.println("Age is : "+age);
System.out.println("Qualification is :" +qualification) ;
}
}
public class Main{
public static void main(String[] args) {
Teacher t1 = new Teacher();
t1.name = "Rock";
t1.age = 27;
t1.qualification = "BSc";
t1.display();
Person p1 = new Person() ;
p1.name = "Hamim";
p1.age = 7;
p1.display();
}
}
+ 6
https://code.sololearn.com/cALBXClUYpc8/?ref=app
edit: Hatsy Rei was faster ;)
+ 3
Denise Roßberg Same changes, basically. :>
+ 3
Thanks all.
+ 2
what's wrong?