欢迎来到计算机考试题库网 考试题库官网
全部科目 > Java认证考试 > SCJP程序员认证考试

单项选择题

Consider the following class:    
class Test(int i) {   
 void test(int i) { 
System.out.println(“I am an int.”);
}   
void test(String s) {  
System.out.println(“I am a string.”);   
 }        
 public static void main(String args) {   
Test t=new Test();    
char ch=“y”;   
t.test(ch);    
}     
}    
Which of the statements below is true?()

    A. Line 5 will not compile, because void methods cannot be overridden.
    B. Line 12 will not compile, because there is no version of test() that rakes a charargument.
    C. The code will compile but will throw an exception at line 12.
    D. The code will compile and produce the following output: I am an int.
    E. The code will compile and produce the following output: I am a String.

点击查看答案&解析