null
zero
some
Compilationfails.
Anexceptionisthrownatruntime.
第1题:
A.null
B.zero
C.some
D.Compilationfails.
E.Anexceptionisthrownatruntime.
第2题:
A.NULL
B.Compilationfails.
C.Thecoderunswithnooutput.
D.Anexceptionisthrownatruntime.
NULLshouldbe"null".
第3题:
A.When compile, some error will occur.
B.When run, some error will occur.
C.Output is zero.
D.Output is null.
第4题:
已知如下代码: public class Test long a[]=new long[10] public static void main (String args[]{ System.out.println(a[6];} 以下( )语句是正确的。
A.Output is null.
B.When running,some error will occur.
C.When compile,some error will occur.
D.Output is 0.
第5题:
现有一个文件file21.txt,其内容是: abCdEf, 执行下列程序之后,输出的结果是______。 package ch1; import java,io.*; public class ex21 { static String name = "ch1\\file21.txt"; public static void main(String[] args) { try { readFile (); } catch(IOException ioe) { System.out.println(ioe.getMessage()); } } static void readFile () throws IOException { BufferedReader br = null; try { File f = new File(name); FileReader fr = new FileReader(f); br = new BufferedReader(fr); String str= br.readLine(); System.out.println(str.toLowerCase()); } finally if(br != null) br.close (); } } }
A.AbCdEf
B.abcdef
C.aBcDeF
D.ABCDEF
第6题:
Giventhefollowingcodefragment:1)Stringstr=null;2)if((str!=null)&&(str.length()>10)){3)System.out.println("morethan10");4)}5)elseif((str!=null)&(str.length()<5)){6)System.out.println("lessthan5");7)}8)else{System.out.println("end");}Whichlinewillcauseerror?()
A.line1
B.line2
C.line5
D.line8
此题需要将代码仔细看清楚,查询没有逻辑错误,if…else的使用没有问题,也没有拼写错误,错误在于第5行的“与”操作符的使用,逻辑操作符(logicaloperator)的“与”应该是&&,而&是位逻辑操作符(bitwiselogicaloperator)的“与”,使用的对象不一样,逻辑操作符的“与”的左右操作数都应该是布尔型(logicalboolan)的值,而位逻辑操作符的左右操作数都是整型(integral)值。
第7题:
阅读下面程序 public class ConcatTest { public static void main(String[] args) { String str1="abc"; String str2="ABC": String str3=str1.concat(str2); System.out.println(str3); } } 程序运行的结果是
A.abc
B.ABC
C.abcABC
D.ABCabc
第8题:
public static void main(String[]args){String str="null";if(str==null){System.out.println("null");}else(str.length()==0){System.out.println("zero");}else{System.out.println("some");}}What is the result?()
A.null
B.zero
C.some
D.Compilationfails.
E.Anexceptionisthrownatruntime.
第9题:
阅读下面程序 public class ConcatTest{ public static void main(String[] args) { String strl = "abc"; String str2 = "ABC"; String str3 = str1.concat(str2); System.out.println(str3); } } 程序的运行结果是:
A.abe
B.ABC
C.abcABC
D.ABCabc
第10题: