File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Abstract method" Watch "Abstract method" New topic

Abstract method

Lancy Mendonca
Ranch Hand

Joined: Aug 08, 2000
Posts: 54
Had a small query about abstract method:
Why is it not possible to say
abstract class one
private abstract void f();
The compiler gives an error message

Sun Certified Java Programmer<BR>Oracle Certified DBA
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
The compiler gives an error because abstarct methods cannot be declared as private. Here's why -
Abstract classes are incomplete classes. Tagging a method as abstract indicates that the subclass needs to override the method to make the implementation complete. However, we also know private methods cannot be overridden because they are not visible outside the class. This makes abstract and private qualifiers mutually exclusive and hence they cannot be used together.
Hope this helps.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Lancy Mendonca
Ranch Hand

Joined: Aug 08, 2000
Posts: 54
Thanks Ajith. Your help is appreciated
I agree. Here's the link:
subject: Abstract method
It's not a secret anymore!