class Computer{ String brand;}class Student{ String name; Computer spc;}public class Test{ public static void main(String[] args){ Computer c = new Computer(); c.brand = "联想"; Student s = new Student(); s.spc = c; System.out.println(s.spc.brand);//这句话的输出是______ c.brand = "HuaWei"; System.out.println(c.brand);//这句话的输出是______ System.out.println(s.spc.brand);//这句话的输出是______ }}
public class Dog{ String name; int age; boolean isLive; public static void main(String[] args){ Dog dog1 = new Dog(); Dog dog2 = new Dog(); } }在上述代码中,有______ 个基本数据类型的属性,有______ 个引用数据类型的属性
public class Dog{ String name; public static void main(String[] args){ Dog dog = new Dog(); } }上面这段代码中,______ 是成员变量,______ 是局部变量。
写一个公共狗类,狗类有两个属性,品种和名字,并且有咬人这个方法。并在main函数中实例化一个狗类的实例对象,引用的名称为dog1,给品种赋值为“金毛”,名字叫“阿毛”,并且调用咬人的方法。public ______ Dog{ String type; String name; void bite(){ System.out.println("咬人"); } public static void main(String[] args){ ______ ______ = ______ Dog(); dog1______ type = "金毛"; ______ .name = "阿毛"; dog1.______ ; }}