File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
kri shan
Ranch Hand
Posts: 1453
  • 0
  • 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
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic