Total members 11890 |It is currently Sat Apr 20, 2024 4:26 am 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
 inheritance in c++     -  
 What is Inheritance?!!     -  
 help me! inheritance     -  
 Inheritance C++ Example     -  
 Inheritance in c++     -  
 Inheritance in java     -  
 @AttributeOverride with Inheritance     -  
 Multiple Inheritance     -  
 single table inheritance     -  
 Inheritance & polymorphism checker code     -  



cron





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