单选题Which command line invocation will produce the output?()Ajava Test 2222Bjava Test 1234Cjava Test 4242Djava Test 4321

题目
单选题
Which command line invocation will produce the output?()
A

 java Test 2222

B

 java Test 1234

C

 java Test 4242

D

 java Test 4321


相似考题
更多“单选题Which command line invocation will produce the output?()A  java Test 2222B  java Test 1234C  java Test 4242D  java Test 4321”相关问题
  • 第1题:

    下列哪个选项的java源文件代码片段是不正确的?

    A.package testpackage; public class Test{ }

    B.import java. io. *; package testpaekage; public class Test { }

    C.import java.io.*; class Person { } public class Test { }

    D.import java.io.*; import java. awt.*; public class Test{ }


    正确答案:B
    解析:Java中的package语句必须是源文件中除去说明以外的第一条语句,导入包语句可以有几个,但是必须位于package语句之后,其他类定义之前,一个源文件中可以有几个类,但最多只能有一个是public的,如果有,则源文件的文件名必须和该类的类名相同。

  • 第2题:

    下列哪个选项的java源文件程序段是不正确的? ( )

    A.package testpackage; public class Test{ }

    B.import java.io.*; package testpackage; public class Test{ }

    C.import java.i.*; class Person{} public class Test{ }

    D.import java.io.*; import java.awt.*; public class Test { }


    正确答案:B

  • 第3题:

    要运行一个名为Test.class的类文件,需要在DOS提示符下输入( )命令。

    A.javac Test

    B.javac Test. class

    C.java Test

    D.java Test. class


    正确答案:C
    解析:javac是Java语言的编译器,用于将源文件编译为字节码文件,所以A、B不正确。 java是Java解释器,用于运行类文件,输入命令时,后面直接跟类名,不加.class,所以C正确。

  • 第4题:

    public class test(  public static void main(string[]args){  string foo = args [1];  string foo = args [2];  string foo = args [3];  }  )  And command line invocation: Java Test red green blue   What is the result?()  

    • A、 Baz has the value of “”
    • B、 Baz has the value of null
    • C、 Baz has the value of “red”
    • D、 Baz has the value of “blue”
    • E、 Bax has the value of “green”
    • F、 The program throws an exception.

    正确答案:F

  • 第5题:

    以下哪些是合法的构造RandomAccessFile对象的代码()。

    • A、RandomAccessFile(new File("D:////myex//dir1//..//test.java"),"rw")
    • B、RandomAccessFile("D:////myex//test.java","r")
    • C、RandomAccessFile("D:////myex//test.java")
    • D、RandomAccessFile("D:////myex//test.java","wr")

    正确答案:A,B

  • 第6题:

    public class Test {  public static void main( String[] args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.println(“baz = “ + baz); }  }   And the command line invocation: java Test red green blue   What is the result?()  

    • A、 baz =
    • B、 baz = null
    • C、 baz = blue
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:E

  • 第7题:

    public class Test{  public static void main( String[] argv ){  // insert statement here  }  }   Which statement, inserted at line 3, produces the following output?()  Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)  

    • A、 assert true;
    • B、 assert false;
    • C、 assert false : true;
    • D、 assert false == true;
    • E、 assert false: false;

    正确答案:C

  • 第8题:

    public class Test {  public static void main(String [] args) {  System.out.println(args.length > 4 &&  args[4].equals(“-d”));  }  }   If the program is invoked using the command line: java Test One Two Three –d   What is the result?()  

    • A、 true
    • B、 false
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:D

  • 第9题:

    单选题
    public class Test {  public static void main(String [] args) {  System.out.println(args.length > 4 &&  args[4].equals(“-d”));  }  }   If the program is invoked using the command line: java Test One Two Three –d   What is the result?()
    A

     true

    B

     false

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: B
    解析: The correct answer to this question is D. The args[4] generates a runtime exception error because there are only 4 strings and the expression args[4] prints the 5th String but like it was said earlier, there are only 4 strings. 

  • 第10题:

    单选题
    public class Test {  public static void main( String[] args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.println(“baz = “ + baz); }  }   And the command line invocation: java Test red green blue   What is the result?()
    A

     baz =

    B

     baz = null

    C

     baz = blue

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


    正确答案: C
    解析: A java.lang.ArrayIndexOutOfBoundsException is thrown because of line 3, should be args[0].

  • 第11题:

    单选题
    public class Test{  public static void main( String[] argv ){  // insert statement here  }  }   Which statement, inserted at line 3, produces the following output?()  Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)
    A

     assert true;

    B

     assert false;

    C

     assert false : true;

    D

     assert false == true;

    E

     assert false: false;


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    public class test(   public static void main(stringargs){   string foo = args [1];   string foo = args ;   string foo = args ;   }   )   And command line invocation:  Java Test red green blue  What is the result? ()
    A

     Baz has the value of “”

    B

     Baz has the value of null

    C

     Baz has the value of “red”

    D

     Baz has the value of “blue”

    E

     Bax has the value of “green”

    F

     The program throws an exception.


    正确答案: F
    解析: 暂无解析

  • 第13题:

    下列( )选项的java源文件代码片段是不正确的。

    A.package testpackage; publicClass Test{}

    B.import java.io.*; package testpackage: publicClass Test{}

    C.import java.io.*; Class Person{} publicClass Test{}

    D.import java.io.*; import java.awt.*; publicClass Test{}


    正确答案:B

  • 第14题:

    阅读下列代码 public class Test2005{ public static void main(String args[]){ String s="Test"; switch(s){ case"Java":System.out.print("Java"); break; case"Language":System.out.print("Lan- guage"); break; case"Test":System.out.print("Test"); break; } } } 其运行结果是( )。

    A.Java

    B.Language

    C.Test

    D.编译时出错


    正确答案:D
    D。【解析】本题考查switch语句的用法。switch语句是多分支语句,即根据表达式的值来执行多个操作中的一个。在switch语句中,”表达式”的返回值类型必须是这几种类型之一:int、byte、char、short。本题中,switch的表达式s是一个字符串Strin9类型的值,它不是int、byte、char、short中的任意一个。因此表达式s的类型不对,编译时出错。

  • 第15题:

    AUNIXusernamedBobwantstoreplacehischessprogramwithanewone,butheisnotsurewheretheoldoneisinstalled.BobiscurrentlyabletorunaJavachessprogramstartingfromhishomedirectory/home/bobusingthecommand:java-classpath/test:/home/bob/downloads/*.jargames.ChessBob’sCLASSPATHisset(atlogintime)to:/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/*.jarWhatisapossiblelocationfortheChess.classfile?()

    A./test/Chess.class

    B./home/bob/Chess.class

    C./test/games/Chess.class

    D./usr/lib/games/Chess.class

    E./home/bob/games/Chess.class


    参考答案:C

  • 第16题:

    public class test {  public static void main(String [] a) {  assert a.length == 1;  }  }  Which two will produce an AssertionError?()

    • A、 java test
    • B、 java -ea test
    • C、 java test file1
    • D、 java -ea test file1
    • E、 java -ea test file1 file2
    • F、 java -ea:test test file1

    正确答案:B,E

  • 第17题:

    一个Applet编译后的类名是Test.class,运行此小程序的命令是Java Test。


    正确答案:错误

  • 第18题:

    public class Test {  public static void main (String[]args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.printIn(“baz = ” + baz);  }  }  And the output:  Baz = 2  Which command line invocation will produce the output?()  

    • A、 Java Test 2222
    • B、 Java Test 1 2 3 4
    • C、 Java Test 4 2 4 2
    • D、 Java Test 4 3 2 1

    正确答案:C

  • 第19题:

    public class test(   public static void main(stringargs){   string foo = args [1];   string foo = args ;   string foo = args ;   }   )   And command line invocation:  Java Test red green blue  What is the result? () 

    • A、 Baz has the value of “”
    • B、 Baz has the value of null
    • C、 Baz has the value of “red”
    • D、 Baz has the value of “blue”
    • E、 Bax has the value of “green”
    • F、 The program throws an exception.

    正确答案:F

  • 第20题:

    A UNIX user named Bob wants to replace his chess program with a new one, but he is not sure where theold one is installed. Bob is currently able to run a Java chess program starting from his home directory /home/bob using the command: java -classpath /test:/home/bob/downloads/*.jar games.Chess Bob’s CLASSPATH is set (at login time) to: /usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/*.jar  What is a possible location for the Chess.class file?()

    • A、/test/Chess.class
    • B、/home/bob/Chess.class
    • C、/test/games/Chess.class
    • D、/usr/lib/games/Chess.class
    • E、/home/bob/games/Chess.class

    正确答案:C

  • 第21题:

    单选题
    public class test(  public static void main(string[]args){  string foo = args [1];  string foo = args [2];  string foo = args [3];  }  )  And command line invocation: Java Test red green blue   What is the result?()
    A

     Baz has the value of “”

    B

     Baz has the value of null

    C

     Baz has the value of “red”

    D

     Baz has the value of “blue”

    E

     Bax has the value of “green”

    F

     The program throws an exception.


    正确答案: F
    解析: 暂无解析

  • 第22题:

    单选题
    public class Test {  public static void main (String[]args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.printIn(“baz = ” + baz);  }  }  And the output:  Baz = 2  Which command line invocation will produce the output?()
    A

     Java Test 2222

    B

     Java Test 1 2 3 4

    C

     Java Test 4 2 4 2

    D

     Java Test 4 3 2 1


    正确答案: B
    解析: 暂无解析

  • 第23题:

    单选题
    public class Test {   public static void main (Stringargs) {   String foo = args[1];   String bar = args;   String baz = args;   System.out.printIn(“baz = ” + baz);  }   }   And the output:  Baz = 2   Which command line invocation will produce the output?()
    A

     Java Test 2222

    B

     Java Test 1 2 3 4

    C

     Java Test 4 2 4 2

    D

     Java Test 4 3 2 1


    正确答案: B
    解析: 暂无解析

  • 第24题:

    单选题
    Which command line invocation will produce the output?()
    A

     java Test 2222

    B

     java Test 1234

    C

     java Test 4242

    D

     java Test 4321


    正确答案: C
    解析: 暂无解析