单选题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) { int x = 0; assert (x > 0): “assertion failed”; System.out.println(“finished”); } } What is the result?()
A
finished
B
Compilation fails.
C
An AssertionError is thrown.
D
An AssertionError is thrown and finished is output.
参考解析
解析:
This question is a bit tricky because it lacks the following information: It should include a statement that says whether or not assertions are enabled. If they are indeed enabled, the
correction answer is C. but if they are not, the correct answer is A. Assertions are not enabled by default so if the question is not changed, the most logical answer is A.
correction answer is C. but if they are not, the correct answer is A. Assertions are not enabled by default so if the question is not changed, the most logical answer is A.
相关考题:
下列语句输出结果为( )。public class test{public static void main(String args[]){byte b=OXA;System.out.println(b);}}A.OXAB.AC.1D.10
下列程序的运行结果是【 】。public class Test {public static void main (String args[]) {String s1="hello!";System.out.println (s1.toUpperCase());}}
下列代码的执行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(7/2); } }A.3.5B.3C.3.0D.3.50
( 8 )阅读下列代码public class Test2{public static void main(String args[]){System.out.println(5/2);}}其执行结果是 【 8 】 。
以下Java应用程序执行入口main方法的声明中,正确的是( )。 A.public static void main()B.public static void main(String[] args)C.public static int main(String[] args)D.public void main(String[] args)
下列哪个是对main( )主方法的正确表示?A.public void static main(String args[ ]){ ... }B.void public static main(String args[ ]){ ... }C.static public void main(String args[ ]){ ... }D.以上都不正确
下列程序的输出结果是class Test{public static void main(String args[]){int n=7;n 下列程序的输出结果是 class Test{ public static void main(String args[]){ int n=7; n<<=3; n=nn+1|n+2^n+3; n>>=2; System.out.println(n); } }A.0B.-1C.14D.64
下列语句输出的结果为( )。 public class test { public static void main(String args[]) { byte b=OXA; System.out.println(b); } }A.OXAB.AC.1D.10
下列( )是对main ()主方法的正确表示。A.public void static main (String args []) {…}B.void public static main (String args []) {…}C.static public void main (String args []) {…}D.以上都不正确
下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello"; s.replace ('r','m'); System.out.println(s); } }A.helloB.HELLOC.hemmoD.HEMMO
以下哪个是Java应用程序main方法的有效定义? A. public static void main();B. public static void main( String args );C. public static void main( String args[] );D. public static void main( Graphics g );E. public static boolean main( String a[] );
以下是JAVA中正确的入口方法是? () A、 public static void main(String[] args){}B、 public static void main(String args){}C、 public void main(String[] args){}D、 public static int main(String[] args){}
Which declarations will allow a class to be started as a standalone program?() A、public void main(String args[])B、public void static main(String args[])C、public static main(String[] argv)D、final public static void main(String [] array)E、public static void main(String args[])
Public class test ( Public static void main (String args[]) ( System.out.printIn (6 ^ 3); ) ) What is the output?()
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?()
下列有关main()方法的签名正确的是哪些?()A、 public static void main(String[] args){}B、 public static void main(){}C、 public static void main(String args[]){}D、 public void static main(String[] args){}
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.
下面哪些选项是正确的main方法说明?()A、 public main(String args[])B、 public static void main(String args[])C、 private static void main(String args[])D、 void main()
作为Java应用程序入口的main方法,其声明格式可以是()。A、public static void main(String[] args)B、public static int main(String[] args)C、public void main(String[] args)D、public int main(String[] args)
声明Java独立应用程序main()方法时,正确表达是()。A、public static void main(String[]args){…}B、private static void main(String args[]){…}C、public void main(String args[]){…}D、public static void main(){…}
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
下面哪些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)
多选题Which declarations will allow a class to be started as a standalone program?()Apublic void main(String args[])Bpublic void static main(String args[])Cpublic static main(String[] argv)Dfinal public static void main(String [] array)Epublic static void main(String args[])
单选题以下是JAVA中正确的入口方法是? ()A public static void main(String[] args){}B public static void main(String args){}C public void main(String[] args){}D public static int main(String[] args){}
填空题Public class test ( Public static void main (String args) ( System.out.printIn (6^3); ) ) What is the output? ()
填空题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.printIn (textString + textBuffer); } ) What is the output?()
单选题下面哪些选项是正确的main方法说明?()A public main(String args[])B public static void main(String args[])C private static void main(String args[])D void main()