This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Super Class method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Super Class method " Watch "Super Class method " New topic
Author

Super Class method

Gina Ruffolo-Daniel
Greenhorn

Joined: Oct 01, 2005
Posts: 19
I am trying to print the both the super and subclass methods at the end of my progam. I am just getting subclass data returned.

Super Class


Sub class

Print Line


Thank you for any help in advance,
Gina
Raghuveer Kumarakrishnan
Ranch Hand

Joined: Mar 13, 2005
Posts: 32
Gina ,

Take a look at this method ,your code gets the superclass info allright but what do you with it?? You just return the subclass info in the method. I hope this helped. If not come back ,we are glad to help


[ October 17, 2005: Message edited by: Raghu Kumar ]

Raghu<br />SCJP 1.4<br />SCWCD 1.4<br />SCBCD 1.3
Gina Ruffolo-Daniel
Greenhorn

Joined: Oct 01, 2005
Posts: 19
Just to make sure I am understanding correctly: I need to add the info retrieved from Super.getPerson(); to my return statement. How is that done with one return statement? is it Resultreturn Result,Result1?
Gina Ruffolo-Daniel
Greenhorn

Joined: Oct 01, 2005
Posts: 19
I think I got it...
Andyjr Robinson
Greenhorn

Joined: Oct 12, 2005
Posts: 6
Gina.

Can't you concatenate it into a single string like you are doing elsewhere within your code ??
Andyjr Robinson
Greenhorn

Joined: Oct 12, 2005
Posts: 6
I think you got it !!

But you can do it in a slightly shorter way:

public String getStudent() {
return super.getPerson() + "\nMajor: " + Major + " GPA: " + gpa;
}

And for efficiency you might like to look into The StringBuffer object !!!
Gina Ruffolo-Daniel
Greenhorn

Joined: Oct 01, 2005
Posts: 19
I think I got it...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Super Class method
 
Similar Threads
HTTP ERROR: 500
Another "Fantastic" Static Method Problem I need help on...
Address Book Java Issues
Exception in thread "main" java.lang.NullPointerException
inheritance homework assignment - im stuck