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

43,863 total views, 347 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.

3,442 Thoughts to “Java Program To Demonstrate Single Inheritance”

  1. Thanks for getting the time to discuss this, I really feel strongly about it and seriously reading excellent on this subject. If doable, as you obtain expertise, would you mind updating your websites with considerably more tips? It truly is very valuable for me.
    ecco shoes outlet http://www.eccooutlet.online

Leave a Comment