Java examples for Object Oriented Design:Inheritance
Create Class Inheritance
public class Main { public static void main(String[] args) { Manager mgr = new Manager(); mgr.setName("Ana Bates"); // Get the name of the manager String mgrName = mgr.getName(); // Display the manager name System.out.println("Manager Name: " + mgrName); }/*from www . j a va 2 s. c o m*/ } class Employee { private String name = "Unknown"; public void setName(String name) { this.name = name; } public String getName() { return name; } } class Manager extends Employee { // No code is needed for now }