• 2021-04-14
    给出程序的运行结果()class Person {String name;...;person.tell();}}
  • Person()姓名:张三,年龄:30

    举一反三

    内容

    • 0

      class Person{ static{ System.out.println(name); } private static String name = "hello"; } class Demo{ public static void main(String[] args){ Person p = null; } }

    • 1

      (6-2)定义如下Person类,(1)处合理的代码是。 class Person { String name, department; int age; public Person(String n) { name = n; } public Person(String n, int a) { name = n; age = a; } public Person(String n, int a, String d) { ① department = d; } }

    • 2

      【多选题】定义了如下Person类,下面()程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } } A. Person [ ] list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; B. Person list[ ]=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; C. Person[ ]  list={new Person("孙悟空"),new Person("猪八戒")}; D. Person  list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")};

    • 3

      中国大学MOOC: public class Person { String name,department; int age; public Person(String n){name=n;} public Person(String n,int a){name=n; age=a;} public Person(String n, String d, int a ){ //调用2个参数的构造函数 department=d; }}

    • 4

      阅读下列的程序 class Person{ static{ System.out.println("static") } Person(){ System.out.println("构造") } } class Demo{ public static void main(String[] args){ Person p = new Person(); } } 下列选项中,程序的运行结果是()