阅读下列的程序 public class Example { public static void main(String[] args) { new Father () { public void show() { System.out.println("helloworld"); } }.show(); } } class Father { public void show() { System.out.println("hellofather"); } } A. B. C. D.
举一反三
- public class Example { public static void main(String[] args) { new Father () { public void show() { System.out.println("helloworld"); } }.show(); } } class Father { public void show() { System.out.println("hellofather"); } }
- 下列的程序的运行结果是( )public class Example { public static void main(String[] args) { new Father () { public void show() { System.out.println("helloworld"); } }.show(); }}class Father { public void show() { System.out.println("hellofather"); }} A: hellofather B: helloworld C: 编译报错 D: 编译通过,运行报错
- 下列程序运行结果是( ) 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"); } }
- 下列程序运行结果是 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"); } }
- 请阅读下面的程序,写出最终的结果: interface Inter { public void show(); } abstract class AbstractInter implements Inter { public void show() { System.out.println("AbstractInter show()"); } } class InterImpl extends AbstractInter { public void show() { System.out.println("InterImpl show()"); } } public class InterImplTest { public static void main(String[] args) { InterImpl i = new InterImpl(); i. show(); } }