a) An abstract method cannot be final b) An abstract method cannot be static c) An abstract method cannot be private d) An abstract method must be specified inside an abstract class only e) An abstract method cannot throw any exceptions Select all valid answers. The answers mentioned were (a),(b),(c)&(d).Should (d) be included since,abstract methods can also be specified within an interface ?
vadiraj vd
Ranch Hand
Joined: Dec 15, 2000
Posts: 68
posted
0
No since by default all the methods in an interface are abstract. So the correct answers are (a),(b),(c) and (d).
regards.
Regards<BR>---------<BR>vadiraj<P><BR>*****************<BR>There's a lot of I in J.<BR>*****************
David Harrigan
Ranch Hand
Joined: Dec 12, 2000
Posts: 52
posted
0
Hiya, An interface cannot have a static member, according to the JLS 2nd Ed. 9.4 Note that a method declared in an interface must not be declared static, or a compile-time error occurs, because static methods cannot be abstract. End Quote.
All methods within an interface are implicitly abstract since there is no implementation. And they are implicilty public, so you cannot declare any private methods (however, you can implement private members in the implementation). A method declared within an interface may not be declared as final, although the implementation of the method in a class that implements the interface can be declared as being final. Methods defined within an interface can be declared as throwing an exception.