1.例11.5引用保护成员
public class Cjava { public static void main(String[]args) { Student1 s1=new Student1(10010,"gabhs",'f',19,"fanog"); s1.show(); } } class Student{ protected int num;protected String name;protected char sex; Student(){} public Student(int n,String nam,char s) { num=n;name=nam;sex=s; } public void display() { System.out.println("num:"+num); System.out.println("name:"+name); System.out.println("sex:"+sex); } } class Student1 extends Student{ private int age;private String addr; public Student1(int n,String nam,char s,int a,String ad) { super(n,nam,s); age=a;addr=ad; } public void show() { System.out.println("num:"+num); System.out.println("name:"+name); System.out.println("sex:"+sex); System.out.println("age:"+age); System.out.println("addres:"+addr); } }
2.没问题
3.明天继续写例题