61. Which can NOT be used in declaring or declaring and initializing an automatic (method local) variable?
A. final
B. static
C. expressions
D. Constants of non-primitive type
E. initialized arrays (such as “ {“Hello”,”Good bye”}”).
62. Given the following incomplete method:
1) public void method(){
2)
3) if (someTestFails()){
4)
5) }
6)
7) }
You want to make this method throw an IOException if,and only if,the method someTestFails() returns a value of true.
Which changes achieve this?
A. Add at line 2:IOException e;
B. Add at line 4:throw e;
C. Add at line 4:throw new IOException();
D. Add at line 6:throw new IOException();
E. Modify the method declaration to indicate that an object of type Exception might be thrown.
63. Given the following definition:
String s = null;
Which code fragments cause an object of type NullPointerException to be thrown?
A. if((s!=null)&(s.length()>0))
B. if((s!=null)&&(s.length()>0))
C. if((s==null)|(s.length()==0))
D. if((s==null)||(s.length()==0))
64. The following is a program
1) class Exsuper{
2) String name;
3) String nick_name;
4)
5) public ExSuper(String s,String t){
6) name = s;
7) nick_name = t;
8) }
9)
10) public string toString(){
11) return name;
12) }
13) }
14)
15) public class Example extends ExSuper{
16)
17) public Example(String s,String t){
18) super(s,t);
19) }
20)
21) public String to String(){
22) return name ”a.k.a” nick_name;
23) }
24)
25) public static void main(String args[]){
26) ExSuper a = new ExSuper(“First”,”1st”);
27) ExSuper b = new Example(“Second”,”2nd”);
28)
29) System.out.println(“a is” a.toString());
30) System.out.println(“b is” b.toString());
31) }
32) }
责任编辑:cyth