This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Abstract class - Whetehere sub class should implement all the abstract methods of base class ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract class - Whetehere sub class should implement all the abstract methods of base class ?" Watch "Abstract class - Whetehere sub class should implement all the abstract methods of base class ?" New topic
Author

Abstract class - Whetehere sub class should implement all the abstract methods of base class ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
public abstract class Vehicle {

abstract int total();

}


public class Car extends Vehicle {

}


Is it mandatory to implement abstract method total in the sub class Car?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

No. But if you don't, Car must also be abstract.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

In other words, if the class is not abstract then yes. After all, a non-abstract class can have no abstract methods, even not inherited from an abstract super class.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Abstract class - Whetehere sub class should implement all the abstract methods of base class ?
 
Similar Threads
Super class constructors
casting
method Overriding - Class Bus extends Vehicle, Class Car extends Vehicle
Abstract Class
Overriding/overloading