| Author |
interface methods
|
Rajani Sudhakar
Ranch Hand
Joined: Apr 28, 2004
Posts: 60
|
|
interface Z {void m1();} // 1 class D implements Z {public final void m1() {}} // 2 class E implements Z {public synchronized void m1() {}} // 3 class G implements Z {public native void m1();} // 4 A Compile-time error is generated at which line? a. 1 b. 2 c. 3 d. 4 e. None of the above Answer : e (none of the above) Interface methods are implicitly public and abstract. How can we apply 'final','synchronized' and 'native' modifiers to the implemeted methods? Thanks in advance.. regards, rajani.
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
The methods within the interface are implicity public and static. That doesn't mean that the class that implements those methods can't make those methods final, as well (or any of the other modifiers, for that matter). Certainly, the implementing class couldn't change the access modifier to private, but make a public, static method final isn't a problem at all.
|
SCJP Tipline, etc.
|
 |
Rajani Sudhakar
Ranch Hand
Joined: Apr 28, 2004
Posts: 60
|
|
Another Question with Interfaces : Is the concept of Nested Interfaces included in the SCJP1.4 exam? And also classes defined within an enclosing interface? If so.. can anyone send me appropriate links to know about nested interfaces? I am entirely confused about nested interfaces.. what are the modifiers applicable to to an interface(nested) ? what are the modifiers used to a class defined within an enclosing interface? A lot of questions revolving at the same time about "Nested Interfaces". I would be greatful if anyone answers my questions.. thanks in advance, regards, rajani.
|
 |
 |
|
|
subject: interface methods
|
|
|