Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 9:17 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: Need Help about Inheritance
PostPosted: Wed Feb 04, 2009 11:51 am 
Offline
Newbie
User avatar

Joined: Thu Jan 22, 2009 3:52 am
Posts: 4
Has thanked: 0 time
Have thanks: 0 time

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 http://www.learn-programming.za.net/pro ... arn08.html


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Need Help about Inheritance
PostPosted: Wed Feb 04, 2009 10:48 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
there must be only one public class and it is the same name of the java file .

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 help me! inheritance
 @AttributeOverride with Inheritance
 single table inheritance
 Inheritance in java
 Inheritance in c++
 Multiple Inheritance
 What is Inheritance?!!

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team