publicclassFoo{staticint[]a;static{a[0]=2;}publicstaticvoidmain(String[]args){}}Whichexceptionorerrorwillbethrownwhenaprogrammerattemptstorunthiscode?() A.java.lang.StackOverflowErrorB.java.lang.IllegalStateExceptionC.java.lang.ExceptionlnlnitializerErrorD.java.lang.ArraylndexOutOfBoundsException
publicclassFoo{staticint[]a;static{a[0]=2;}publicstaticvoidmain(String[]args){}}Whichexceptionorerrorwillbethrownwhenaprogrammerattemptstorunthiscode?()
A.java.lang.StackOverflowError
B.java.lang.IllegalStateException
C.java.lang.ExceptionlnlnitializerError
D.java.lang.ArraylndexOutOfBoundsException
相关考题:
Given1.publicclassFoo{2.publicstaticvoidmain(String[]args)}3.try{return;}4.finally{Syste.out.printIn(Finally”);}5.}6.}Whatistheresult()? A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Finally”.C.Thecodecomiles.Butanexceptionisthrownatruntime.D.Thecodewillnotcompilebecausethecatchblockismissing.
publicclassFoo{publicstaticvoidmain(String[]args){inti=1;intj=i++;if((i++j)(i++==j)){i+=j;}}}Whatisthefinalvalueofi?() A.1B.2C.3D.4E.5
publicclassfoo{staticStrings;publicstaticvoidmain(String[]args){system.out.printIn(s=”+s);}}Whatistheresult?() A.Thecodecompilesand“s=”isprinted.B.Thecodecompilesand“s=null”isprinted.C.Thecodedoesnotcompilebecausestringsisnotinitialized.D.Thecodedoesnotcompilebecausestringscannotbereferenced.E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.
publicclassfoo{publicstaticvoidmain(string[]args)try{return;}finally{system.out.printIn(Finally”);}}Whatistheresult?() A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Finally”C.Thecodecompiles,butanexceptionisthrownatruntime.D.Thecodewillnotcompilebecausethecatchblockismissing.
publicclassfoo{publicstaticvoidmain(String[]args){Strings;system.out.printIn(s=”+s);}}Whatistheresult?() A.Thecodecompilesand“s=”isprinted.B.Thecodecompilesand“s=null”isprinted.C.Thecodedoesnotcompilebecausestringsisnotinitialized.D.Thecodedoesnotcompilebecausestringscannotbereferenced.E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.
publicclassFoo{publicvoidmain(String[]args){System.out.println(Hello”+args[0]);}}Whatistheresultifthiscodeisexecutedwiththecommandline?() A.HelloB.HelloFooC.HelloworldD.Compilationfails.E.Thecodedoesnotrun.
publicclassFoo{publicstaticvoidmain(String[]args){try{return;}finally{System.out.println(Finally”);}}}Whatistheresult?() A.FinallyB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.
以下哪个是有效的Java程序入口函数?A.public static void main(String[] args);B.public static void main();C.public static int main(String[] args);D.public static void main(int argc, String[] args)
以下哪个main方法是正确的?A.public static void main(string[] args)B.public static void Main(String[] args)C.public static void main(String[] args)D.public static main(String[] args)E.public void main(String[] args)