File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Associate Certification (OCAJP 7) and the fly likes Abstract method overriding method in parent class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7)
Bookmark "Abstract method overriding method in parent class" Watch "Abstract method overriding method in parent class" New topic
Author

Abstract method overriding method in parent class

Thomas Hauck
Ranch Hand

Joined: Jun 07, 2011
Posts: 54
Question: Is it still considered method overriding when the abstract method in the abstract class Mammal has the same name as
the non-abstract method in Animal?
Is it still considered polymorphism when the overriding method in the subclass is abstract?



Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4905
    
  10

Thomas Hauck wrote:Is it still considered method overriding when the abstract method in the abstract class Mammal has the same name as the non-abstract method in Animal?

Yes! The class Mammal is overriding the method speak from class Animal, but instead of providing an implementation it forces the (concrete) subclass to provide the implementation.

Thomas Hauck wrote:Is it still considered polymorphism when the overriding method in the subclass is abstract?

I would say "no", because a subclass with an abstract method must be abstract itself and you can't instantiate from this class. So in your example Animal a = new Mammal(); won't compile. When you create an anonymous subclass of Mammal by implementing the abstract method you'll definitely have polymorphism as shown in this example:


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract method overriding method in parent class
 
Similar Threads
Constructor of a parent class
Another Package Question
Abstract Classes / Methods
Verification of constructor calling
lets see if someone can solve this mistry