题目内容

public class A{ int i = 20; static int j = 20; public A(){ } public A(int m, int n){ i = m; j = n; } public static void main(String[] args){ A a1 = new A(0,30); A a2 = new A(); System.out.println( a1.i ); System.out.println( a1.j ); System.out.println( a2.i ); System.out.println( a2.j ); }}如上这段代码的输出结果是______ ,______ ,______ ,______ 。

查看答案
更多问题

创建一个狗类,包括品种和名字两个属性,使用构造方法初始化这两个属性,在main方法中创建1个该类的实例对象,将两个属性赋值为“金毛”和“阿毛”。public class Dog{ String name ; String type ; public ______ ( String n, String t){ ______ = n ; ______ = t ; } public static void main(String[] args){ ______ d = new ______ ( ______ , ______ ) ; }}

补全代码,完成Student类的构造方法。public class Student{ int studnentNo; String studentName; public ______ ( ){ }}

构造器,又称为构造方法,英文名为______

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);//这句话的输出是______ }}

答案查题题库