File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract Method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Abstract Method" Watch "Abstract Method" New topic
Author

Abstract Method

Savio Mascarenhas
Ranch Hand

Joined: Nov 29, 2000
Posts: 108
Which of the following statements are true?

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
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract Method
 
Similar Threads
Declarations
Abstract Methods
ambiguous statements
should abstart have returntrype compulsoryly
Static