Saturday, November 16, 2013

java program to Implement this and super Keyword

Program to Implement this and super Keyword
class vehicle
{
int id;
String color;
vehicle(int regno,String color)
{
id = regno;
this.color = color;
}
}
class vchl extends vehicle
{
int id;
String color;
vchl(int i1,int i2,String s1,String s2)
{
super(i2,s2);
id = i1;
color = s1;
}
void pdata()
{
System.out.print(super.id);
}
void ddata()
{
System.out.print(super.color);
}
public static void main(String arg[])
{
vchl v = new vchl(10,2334,"GREY","WHITE");
System.out.print("Vehicle color is ");
v.ddata();
System.out.print("\nVehicle number is ");
v.pdata();
System.out.println("\nVehicle engine color is "
+ v.color);
System.out.println("Vehicle engine id is " + v.id);
}
}
class single_inherit
{
public static void main(String a[])
{
radha m = new radha();
m.get(520,22000);
m.show1();
}
}

No comments:

Post a Comment