Simple Inheritance
class Parent {
int age = 30;
String name = "smith";
public void display() {
System.out.println("age: " + age);
System.out.println("name: " + name);
}
}
public class SimpleInheritance extends Parent { /*Now the class SimpleInheritance contains
all the members of the class Parent */
public static void main(String[] args) {
SimpleInheritance si = new SimpleInheritance();
si.display();
}
}
Output:
age: 30
name: smith