public class Animal { private String f_name; private int f_id; public Animal(String myName1, int myid1) { f_name = myName1; f_id = myid1; } public void eat() { System.out.println(f_name+" is eat"); } public void sleep() { System.out.println(f_name+" is sleep"); } public void introduction() { System.out.println("hello , i'm is " + f_id + "----" + f_name + "."); } }
public class Penguin extends Animal { public Penguin(String myName2, int myid2) { super(myName2, myid2); } public static void main(String[] args) { Animal am = new Animal("QI-E",111); am.eat(); am.sleep(); am.introduction(); } }