请说出下列程序的输出结果。 class Cry { public void cry() { System.out.println("大家好"); } } public class E { public static void main(String args[]) { Cry hello=new Cry() { public void cry() { System.out.println("大家好,祝工作顺利!"); } }; hello.cry(); } }
举一反三
- 中国大学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”) ; } }
- 下列程序运行结果是 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"); } }
- 下列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 MyMain{ public static void main(String args){ System.out.println(“Hello Java”); } }