举一反三
- public ______ HelloWorld { public static void main(String[] args) { System.out.println("Hello World !")______ }}
- 下列代码执行结果是?( ) class HelloWorld { public static void modifyString(final String str) { str = "Hello World!"; } public static void main(String[] args) { String a = new String("Hello Java"); modifyString(a); System.out.println(“a = ” + a); } } A: a = Hello Java B: a = Hello World C: 代码编译错误 D: 运行时异常
- 给定如下java 代码,在下划线处填入( ),代表HelloWorld 类具有main方法,可以独立运行。public class Helloworld { _______{ System.out.println( “ hello world” ) ; } } A: public static void main( String args ) B: static void main( String args[ ] ) C: public static void main( String[ ] strs ) D: public static main( String args[ ] )
- 下列程序运行结果是( ) 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 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"); } }
内容
- 0
下列的程序的运行结果是( )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: 编译通过,运行报错
- 1
下列程序运行结果是 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"); } }
- 2
下面程序的运行结果是public class Demo { public static void main(String[] args) { new Object(){ public void show(){ System.out.println("helloworld"); } }.show(); }} A: 什么也不输出 B: helloworld C: 编译报错 D: 编译通过,运行报错
- 3
阅读下列的程序 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.
- 4
package week01 Public class HelloWorld { public static mian(string args) { system.out.println(“Hello World!”); } } 上述源程序中语法错误共有 处?