下列程序运行结果是( ) 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..."); } }
举一反三
- 下列程序运行结果是 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"); } }
- 下列程序的运行结果是( )class Demo{private String name;Demo(String name){this.name = name;}private static void show(){System.out.println(name)}public static void main(String[] args){Demo d = new Demo(“lisa”);d.show();}}
- 下列程序运行结果是( ) 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"); } }
- (7-1)以下程序的运行结果是( )。 class A{ A(){ System.out.print(10); } } public class Demo extends A { public static void main(String[] args) { new A(); new Demo(); } }
- 下列程序的执行结果是 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(); } }