public classYippee{ public static void main(String[]args){ for(intx=1;xSystem.out.print(args[x]+""); } } } and two separate command line invocations:j avaYippee javaYippee1234 What is the result?()A、No output is produced. 123B、No output is produced. 234C、No output is produced. 1234D、An exception is thrown at runtime. 123E、An exception is thrown at runtime. 234F、An exception is thrown at runtime. 1234
public classYippee{ public static void main(String[]args){ for(intx=1;xSystem.out.print(args[x]+""); } } } and two separate command line invocations:j avaYippee javaYippee1234 What is the result?()
- A、No output is produced. 123
- B、No output is produced. 234
- C、No output is produced. 1234
- D、An exception is thrown at runtime. 123
- E、An exception is thrown at runtime. 234
- F、An exception is thrown at runtime. 1234
相关考题:
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 2222B、 Java Test 1 2 3 4C、 Java Test 4 2 4 2D、 Java Test 4 3 2 1
Public class test ( Public static void main (String args[]) ( System.out.printIn (6 ^ 3); ) ) What is the output?()
public class WhileFoo { public static void main (String []args) { int x= 1, y = 6; while (y--) {x--;} system.out.printIn(“x=” + x “y =” + y); } } What is the result?() A、 The output is x = 6 y = 0B、 The output is x = 7 y = 0C、 The output is x = 6 y = -1D、 The output is x = 7 y = -1E、 Compilation will fail.
public class Alpha{ public static void main( string[] args ){ if ( args.length == 2 ) { if ( args.[0].equalsIgnoreCase(“-b”) ) System.out.println( new Boolean( args[1] )); } } } And the code is invoked by using the command: java Alpha –b TRUE What is the result?() A、 trueB、 nullC、 falseD、 Compilation fails.E、 The code runs with no output.F、 An exception is thrown at runtime.
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?() A、 NULLB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.
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 = nullC、 baz = blueD、 Compilation fails.E、 An exception is thrown at runtime.
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 2222B、 Java Test 1 2 3 4C、 Java Test 4 2 4 2D、 Java Test 4 3 2 1
public class Yippee { public static void main(String [] args) { for(int x = 1; x args.length; x++) { System.out.print(args[x] +“ “); } } } and two separate command line invocations: java Yippee java Yippee 1234 What is the result?() A、 No output is produced. 123B、 No output is produced. 234C、 No output is produced. 1234D、 An exception is thrown at runtime. 123E、 An exception is thrown at runtime. 234F、 An exception is thrown at rijntime. 1234
Public class test ( Public static void stringReplace (String text) ( Text = text.replace (‘j’ , ‘i’); ) public static void bufferReplace (StringBuffer text) ( text = text.append (“C”) ) public static void main (String args[]} ( String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”); stringReplace (textString); bufferReplace (textBuffer); System.out.printLn (textString + textBuffer); ) ) What is the output?()
public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } What is the result?()A、 FinallyB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.
public class IfTest ( public static void main(string[]args) { int x = 3; int y = 1; if (x = y) system.out.printIn(“Not equal”); else system.out.printIn(“Equal”); } ) What is the result?() A、 The output is “Equal”B、 The output in “Not Equal”C、 An error at line 5 causes compilation to fall.D、 The program executes but does not print a message.
Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?() CODE FRAGMENT a: public static void main(String args[]) { if (args.length != 0) System.out.println(args[args.length-1]); } CODE FRAGMENT b: public static void main(String args[]) { try { System.out.println(args[args.length]); } catch (ArrayIndexOutOfBoundsException e) {} } CODE FRAGMENT c: public static void main(String args[]) { int ix = args.length; String last = args[ix]; if (ix != 0) System.out.println(last); } CODE FRAGMENT d: public static void main(String args[]) { int ix = args.length-1; if (ix 0) System.out.println(args[ix]); } CODE FRAGMENT e: public static void main(String args[]) { try { System.out.println(args[args.length-1]); }catch (NullPointerException e) {} } A、Code fragment a.B、Code fragment b.C、Code fragment c.D、Code fragment d.E、Code fragment e.
public class Test { public static void main(String[] args) { int x = 0; assert (x 0): “assertion failed”; System.out.println(“finished”); } } What is the result?() A、 finishedB、 Compilation fails.C、 An AssertionError is thrown.D、 An AssertionError is thrown and finished is output.
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、 trueB、 falseC、 Compilation fails.D、 An exception is thrown at runtime.
下面哪些main方法可用于程序执行()A、public static void main(String[]args)B、public static void main(String[]x)C、public static void main(Stringargs[])D、public void main(String[]args)
单选题public class Yippee { public static void main(String [] args) { for(int x = 1; x args.length; x++) { System.out.print(args[x] +“ “); } } } and two separate command line invocations: java Yippee java Yippee 1234 What is the result?()A No output is produced. 123B No output is produced. 234C No output is produced. 1234D An exception is thrown at runtime. 123E An exception is thrown at runtime. 234F An exception is thrown at rijntime. 1234
填空题Public class test ( Public static void stringReplace (String text) ( Text = text.replace (‘j’ , ‘i’); ) public static void bufferReplace (StringBuffer text) ( text = text.append (“C”) ) public static void main (String args[]} ( String textString = new String (“java”); StringBuffer text BufferString = new StringBuffer (“java”); stringReplace (textString); BufferReplace (textBuffer); System.out.printLn (textString + textBuffer); ) ) What is the output?()
单选题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 trueB falseC Compilation fails.D An exception is thrown at runtime.
单选题public class IfTest ( public static void main(string[]args) { int x = 3; int y = 1; if (x = y) system.out.printIn(“Not equal”); else system.out.printIn(“Equal”); } ) What is the result?()A The output is “Equal”B The output in “Not Equal”C An error at line 5 causes compilation to fall.D The program executes but does not print a message.
单选题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 = nullC baz = blueD Compilation fails.E An exception is thrown at runtime.
单选题Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?() CODE FRAGMENT a: public static void main(String args[]) { if (args.length != 0) System.out.println(args[args.length-1]); } CODE FRAGMENT b: public static void main(String args[]) { try { System.out.println(args[args.length]); } catch (ArrayIndexOutOfBoundsException e) {} } CODE FRAGMENT c: public static void main(String args[]) { int ix = args.length; String last = args[ix]; if (ix != 0) System.out.println(last); } CODE FRAGMENT d: public static void main(String args[]) { int ix = args.length-1; if (ix 0) System.out.println(args[ix]); } CODE FRAGMENT e: public static void main(String args[]) { try { System.out.println(args[args.length-1]); }catch (NullPointerException e) {} }ACode fragment a.BCode fragment b.CCode fragment c.DCode fragment d.ECode fragment e.
单选题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 2222B Java Test 1 2 3 4C Java Test 4 2 4 2D Java Test 4 3 2 1
单选题public classYippee{ public static void main(String[]args){ for(intx=1;xSystem.out.print(args[x]+""); } } } and two separate command line invocations:j avaYippee javaYippee1234 What is the result?()ANo output is produced. 123BNo output is produced. 234CNo output is produced. 1234DAn exception is thrown at runtime. 123EAn exception is thrown at runtime. 234FAn exception is thrown at runtime. 1234
单选题public class Alpha{ public static void main( string[] args ){ if ( args.length == 2 ) { if ( args.[0].equalsIgnoreCase(“-b”) ) System.out.println( new Boolean( args[1] )); } } } And the code is invoked by using the command: java Alpha –b TRUE What is the result?()A trueB nullC falseD Compilation fails.E The code runs with no output.F An exception is thrown at runtime.
单选题public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()A NULLB Compilation fails.C The code runs with no output.D An exception is thrown at runtime.
填空题Public class test ( Public static void main (String args[]) ( System.out.printIn (6 ^ 3); ) ) What is the output?()
单选题public class Test { public static void main(String[] args) { int x = 0; assert (x 0): “assertion failed”; System.out.println(“finished”); } } What is the result?()A finishedB Compilation fails.C An AssertionError is thrown.D An AssertionError is thrown and finished is output.