Wed Feb 04, 2009 11:51 am
class Person
{
private String name;
public void setName(String n)
{
name = n;
}
public String getName()
{
return name;
}
}
class Student extends Person
{
private String stuNum;
public void setStuNum(String sn)
{
stuNum = sn;
}
public String getStuNum()
{
return stuNum;
}
}
public class TestInheritance
{
public static void main(String[] args)
{
Student stu = new Student();
stu.setName("John Smith");
stu.setStuNum("12345");
System.out.println("Student Name: " + stu.getName());
System.out.println("Student Number: " + stu.getStuNum());
}
}
http://www.learn-programming.za.net/pro ... arn08.html
Wed Feb 04, 2009 10:48 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.