• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
kri shan
Ranch Hand
Posts: 1489
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. But if you don't, Car must also be abstract.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!