Java programs for beginners in eclipse IDE
Java single inheritance example program using eclipse IDE
package javaproject1;
class Vehicle
{
double speed=80;
void go()
{
System.out.println("This vehicle is moving,Vehicle speed is :"+speed);
}
void stop()
{
System.out.println("This vehicle is stopped");
}
}
class Car extends Vehicle
{
int wheel=4;
int door=4;
}
class Inherits
{
public static void main(String a[])
{
Car car=new Car();
System.out.println("Vehicle speed = "+car.speed);
car.go();
System.out.println("This vehicle has :"+car.wheel+" wheel");
}
}
Short explanation of single inheritance in java
Comments
Post a Comment