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 hi waht is diffrence b/w this abstract method and overridding 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 "hi waht is diffrence b/w this abstract method and overridding" Watch "hi waht is diffrence b/w this abstract method and overridding" New topic
Author

hi waht is diffrence b/w this abstract method and overridding

giribabu venugopal
Greenhorn

Joined: Jun 24, 2004
Posts: 17
//chack this code i want ot overridea swell as acces abstarct method same /time is it possible.--?



Edited by Corey McGlone: Added CODE Tags and Reformatted Code

[ June 29, 2004: Message edited by: Corey McGlone ]
[ June 29, 2004: Message edited by: Corey McGlone ]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
An abstract method is nothing more than a declaration. It simply states that any class that wishes to extend this class must override this method and provide its own implementation. Of course, on the other hand, you're free to override any non-static method, abstract or not. Abstract methods, however, must be overridden.

In addition, you can "invoke the abstract method" on a reference of the Superclass type. Take this example:



Why does this work? Well, the compiler knows that the reference variable s can't possibly reference an object of type Super. Why can't it? Super is defined as an abstract class - it can't be instantiated. Therefore, we know that whatever s references at runtime will be a subclass of Super and, because doIt() is an abstract method defined within Super, we know that whatever object s references will have to provide an implementation for that method. With all of that knowledge in hand, we can determine that the polymorphic call will execute safely.


SCJP Tipline, etc.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
What happens when you run this code? (I suppose you uncomment main() before you run it).


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: hi waht is diffrence b/w this abstract method and overridding
 
Similar Threads
Question about constructor chaining...
Math.abs()
abstract
Inherit private member
Program on OOP