Java Practice Exercise – Abstract class

  • Create a Java application to find the area of different shapes using abstract class. Use the abstract class Shape that include two integers and an empty method named printArea(). Construct the classes Rectangle, Triangle and Circle inherited from the class Shape. The Derived classes should include only the method printArea() that print the area of the given shape
  • Define an abstract class “car” with members reg_no, model, reg_date. Define two subclasses of this class – “transportVehicles” (validity_no, start_date, period) and “privateVehicle” (owner_name, owner_address). Define appropriate constructors. Create n objects which could be of either transportVehicles or privateVehicle class by asking the user’s choice. Display details of all “privateVehicle” objects and all “transportVehicles” objects
  • Create a java abstract class to implement stack concept. Check for the overflow and empty conditions