Sample Run
/*
* Inheritance example
*/
package testcar;
/**
*
* @author Somnath
*/
class Car
{
int noofwheels;
void start()
{
System.out.println("The car has started");
}
void start(int t, int tt)
{
System.out.println("Starting "+t+" cars");
}
void move()
{
System.out.println("The car is moving");
}
void stop()
{
System.out.println("The car has stopped");
}
}
public class TestCar extends Car {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
TestCar mytestcar = new TestCar();
Car mycar = new Car();
mycar.start();
mycar.start(100, 77);
mycar.move();
mycar.stop();
mytestcar.start();
mytestcar.start(90, 88);
mytestcar.noofwheels=9;
}
}
No comments:
Post a Comment