题目内容

this关键字用在构造方法中,指向正要初始化的对象。

查看答案
更多问题

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 ______ ( ){ }}

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

答案查题题库