SCJP 1.6版考題 029

出自 陳富國維基館
前往: 導覽搜尋
1. public class A{
l2.   public void doit(){
l3.        }
l4.   public String doit(){
l5.            return "a";
l6.   }
l7.   public double doit(int x){
l8.           return 1.0;
l9.        }
10.}


What is the result?

  A. An exception is thrown at runtime.
  B. Compilation fails because of an error in line 7.
  C. Compilation fails because of an error in line 4.
  D. Compilation succeeds and no runtime errors with class A occur.

解答


Ans: C

解說: 同一個類別中,方法若名字一樣,參數列必需不一樣!