Total members 11893 |It is currently Mon Nov 04, 2024 11:06 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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



I CAN GET IT RUN ?? pls tell me the solution.
why person class and student class don;t have keyword public ?
This code can be found at
Code:
http://www.learn-programming.za.net/pro ... arn08.html





Author:
Newbie
User avatar Posts: 4
Have thanks: 0 time

there must be only one public class and it is the same name of the java file .

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Need Help about Inheritance
 What is Inheritance?!!     -  
 help me! inheritance     -  
 Inheritance C++ Example     -  
 Inheritance in c++     -  
 inheritance in c++     -  
 @AttributeOverride with Inheritance     -  
 Multiple Inheritance     -  
 Inheritance in java     -  
 single table inheritance     -  
 Inheritance & polymorphism checker code     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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