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 Test{ public static void main(String args[]) { String str = new String("World"); char ch[] = {'H','e','l','l','o'}; change(str,ch); System.out.println(str + "and" + ch); } public static void change(String str, char ch[]) { str = "Changed"; ch[0] = ' C'; }}运行后输出的结果是: A: Changed and Cello B: World and Cello C: World and CelloChanged and Hello D: World and Hello
- 下面程序段的输出结果是 public class A{ public static void main(String args[]) { String str ="Hello,"; str=str+"Guys!"; System.out.println(str); } }
- 运行下面程序段的结果是:( )。 public class MyMain{ public static void main(String args){ System.out.println(“Hello Java”); } }
- public ______ HelloWorld { public static void main(String[] args) { System.out.println("Hello World !")______ }}
内容
- 0
下列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("您好");
- 1
程序Helloworld.java编译错误。( )public class HelloWorld { public static void main(String[] args){ system.out.println("Hello World!"); } }
- 2
写出下面程序的运行结果 【15】 import java.io.*; public class abc public static void main(String args[]) String s1="Hello!"; String s2=new String("World!"); System.out.println(s1.concat(s2));
- 3
给定一个java程序的代码片断如下,运行后正确的输出结果是( )。String s=”hello, world”;String str = s.replace(“,” , ” ”);System.out.println(str); A: hello world; B: hello, world C: HELLO WORLD D: HELLO ,WORLD;
- 4
下列程序运行结果是 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"); } }