Witshaper is the Professional (Computing Skills, English Learning and Soft Skills) Skill Development Training Center. We provide Professional IT Courses and Soft Skill Training in Dehradun to Students, Employees and organization. Who wish to pursue a career in IT Technology. Witshaper is led by a motivated team of IT experts and Soft Skill Professionals. We provide high quality trainings. Our Emphasis is on giving the practical knowledge to the students, so that they will get to know in depth and never forget what they opt, we provide to the students real learning environment. Witshaper prepares students and professionals to be the part of this growing industry. Be a part of Witshaper and get your dreams successful

Wednesday 20 May 2015

java program to show th concept of inheritance

class Player
{
public String name;
public String Country;
public int JersyNo;
public int age;
public void setdata(String a,String b,int c,int d)
{
name=a;
Country=b;
JersyNo=c;
age=d;
}
public void getdata()
{
System.out.println("Name is"+name);
System.out.println("Country is is"+Country);
System.out.println("JersyNo is"+JersyNo);
System.out.println("Age is"+age);
}
}
class Cricket_Player extends Player
{
public void setdata(String a,String b,int c,int d)
{
name=a;
Country=b;
JersyNo=c;
age=d;
}
}
class Football_Player extends Player
{
public void setdata(String a,String b,int c,int d)
{
name=a;
Country=b;
JersyNo=c;
age=d;
}
}
class Hockey_Player extends Player
{
public void setdata(String a,String b,int c,int d)
{
name=a;
Country=b;
JersyNo=c;
age=d;
}

}
class PlayerMain
{
public static void main(String args[])
{
Player p=new Player();
Cricket_Player c=new Cricket_Player();
System.out.println("Detail of Cricket player is");
c.setdata("Rahul Dravid","India",19,40);
c.getdata();
System.out.println("Detail of Hockey player is");
Hockey_Player h=new Hockey_Player();
h.setdata("Sandeep singh","India",4,26);
h.getdata();
System.out.println("Detail of Football player is");
Football_Player f=new Football_Player();
f.setdata("Cristiano Ronaldo","PORTUGAL",23,30);
f.getdata();
}
}

No comments:

Post a Comment