(6-4)定义了Demo类如下。在该类中,数据成员名是( ),构造方法名是( ),当该类的对象被释放之前有可能被系统自动调用的方法名是( )。
public class Demo{
private int data;
public Demo(){
data=0;
}
public void show(){
System.out.println("data="+data);
}
protected void finalize() throws Throwable{
System.out.println("data is "+data);
super.finalize();
}
public static void main(String[] arge){
}
}
public class Demo{
private int data;
public Demo(){
data=0;
}
public void show(){
System.out.println("data="+data);
}
protected void finalize() throws Throwable{
System.out.println("data is "+data);
super.finalize();
}
public static void main(String[] arge){
}
}
举一反三
- 下列程序运行结果是( ) public class Demo { public static void main(String[] args) { Demo demo = new Demo(); demo.show(new Car() { public void run() { System.out.println("demo run"); } }); } public void show(Car c) { c.run(); } }abstract class Car { public void run() { System.out.println("car run..."); } }
- 在Demo类中 public class Demo{ public Demo(){} public void Demo(int x){} } 构造方法Demo重载了
- 下列程序运行结果是 public class Demo { public static void main(String[] args) { Object obj=new Father(){ public void show(){ System.out.println("helloworld"); } }; obj.show(); } } class Father{ public void show(){ System.out.println("hello father"); } }
- 下列ABCD注释标注的哪行代码有错public class Demo { public static void main(String args[]) { System.out.println("Java"); system.out.println("hello"); System.out.println("你好"); } } A: public class Demo B: public static void main(String args[]) C: system.out.println("ok"); D: System.out.println("您好");
- 下列程序的执行结果是 public class TestDemo { public void fun() { static int i = 0; i++; System.out.println(i); } public static void main(String args[]) { Demo d = new Demo(); d.fun(); } }