Saturday, November 16, 2013

java Program to Implement Thread using Runnable Interface

Program to Implement Thread using Runnable Interface
class A implements Runnable
{
public void run()
{
for(int i=0; i<20; i++)
{
System.out.println(i);
}
}
}
class Run1
{
public static void main(String args[])
{
A a1 = new A();
Thread t = new Thread(a1);
t.start();
}
}

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();
}
}