阅读下列的程序
class Person{
static{
System.out.println("static")
}
Person(){
System.out.println("构造")
}
}
class Demo{
public static void main(String[] args){
Person p = new Person();
}
}
下列选项中,程序的运行结果是()
class Person{
static{
System.out.println("static")
}
Person(){
System.out.println("构造")
}
}
class Demo{
public static void main(String[] args){
Person p = new Person();
}
}
下列选项中,程序的运行结果是()
举一反三
- class Person{ static{ System.out.println(name); } private static String name = "hello"; } class Demo{ public static void main(String[] args){ Person p = null; } }
- 阅读下面的代码: class Person{ void say(){ System.out.println("hello"); } } class Example{ public static void main(String[] args){ Person p1 = new Person(); Person p2 = new Person(); p2.say(); p1.say(); p2=null; p2.say(); } } 下列选项中,哪个是程序的输出结果?()
- 请阅读下面的程序代码,选择正确的运行结果 Class Person{ void say(){ System.out.println(“hello”); } } class Example{ public static void main(String[] args){ Person p2 = new Person(); Person p1 = new Person(); p1.say(); p2.say();} }
- 中国大学MOOC: 下列程序的运行结果是______。public class Person {static int arr[ ]=new int[10];public static void main(String args ) { System.out.println(arr[9]);}}
- 中国大学MOOC: 下列代码中构造方法的返回类型是()public class Village { Village () { System .out .println(“hiding in Village”) ; } public static void main( String args [ ]) { Village c =new Village ( ) ;}class Village { public static void main( String args [ ]) { Village c =new Village ( ) ; } Village () { System .out .println(“hiding in Village”) ; } }