单选题:Given code below:
Given code below:
```Java
class Base{
public final void method() {
System.out.println("Base.method");
}
}
public final class Fin extends Base{
public void method() {
System.out.println("Fin.method");
}
public static void main(String argv[]){
Base b = new Fin();
b.method();
}
}
```
While one below is correct? @[C](2)
A. It does not compile because of method() in Fin is not defined final as its base one
B. It does not compile because Fin can not be final
C. It does not compile because of method() in Base final so no function can override it in derived classes
D. It compiles and prints Fin.method
A.It does not compile because of method() in Fin is not defined final as its base one
B.It does not compile because Fin can not be final
C.It does not compile because of method() in Base final so no function can override it in derived classes
D.It compiles and prints Fin.method
答案:C
```Java
class Base{
public final void method() {
System.out.println("Base.method");
}
}
public final class Fin extends Base{
public void method() {
System.out.println("Fin.method");
}
public static void main(String argv[]){
Base b = new Fin();
b.method();
}
}
```
While one below is correct? @[C](2)
A. It does not compile because of method() in Fin is not defined final as its base one
B. It does not compile because Fin can not be final
C. It does not compile because of method() in Base final so no function can override it in derived classes
D. It compiles and prints Fin.method
A.It does not compile because of method() in Fin is not defined final as its base one
B.It does not compile because Fin can not be final
C.It does not compile because of method() in Base final so no function can override it in derived classes
D.It compiles and prints Fin.method
答案:C