Wednesday, 19 August 2015

Java Tutorial : Inheritance Example Vehicle


Click here to watch in Youtube :
https://www.youtube.com/watch?v=tSVtLPh3X8o&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge

Car.java
/*
 * Super class(Parent)
 */
class Vehicle
{
    String vehicleType;
}

/*
 * Sub class(Child)
 */
public class Car extends Vehicle
{

    String modelType;

    public void showDetail()
    {
        /*
         * accessing Vehicle class member.
         */
        vehicleType = "Car"; 
        modelType = "sports";
        System.out.println(modelType + " " + vehicleType);
    }

    public static void main(String[] args)
    {
        Car car = new Car();
        car.showDetail();
    }
}
Output
sports Car

To Download InheritanceDemoVehicleApp Project Click the below link
https://sites.google.com/site/javaee4321/java/InheritanceDemoVehicleApp.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge