class Teacher
{

int id;
String name;
String add;

void acceptid(int id)
{
this.id=id;
}

int showid()
{

return id;
}

void acceptname(String name)
{

this.name=name;
}

String showname()
{
return name;
}

void acceptadd(String add)
{

this.add=add;
}

String showadd()
{
return add;
}
}

class Single extends Teacher
{

double sal;

void acceptsal(double sal)
{

this.sal=sal;
}

double showsal()
{
return sal;
}

}

class Single_Inheritance
{
public static void main(String args[])
{
Single s=new Single();
s.acceptid(12);
s.acceptname(“Ram”);
s.acceptadd(“Hyderabad”);
s.acceptsal(23456220);

System.out.println(“Teacher:\nid : “+s.showid());
System.out.println(“Name : “+s.showname());
System.out.println(“Address : “+s.showadd());
System.out.println(“Salary : “+s.showsal());
}
}

83,497 total views, 26 views today

Get Free Email Updates..!
Join us for FREE to get instant email updates..! GobsInfo- Everything Unlimited
We hate spam. Your email address will not be sold or shared with anyone else.

6,385 Thoughts to “Java Program To Demonstrate Single Inheritance”

  1. cheap cialis prices canada
    buy cialis online
    cheap cialis pills online

Leave a Comment