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 Problem with code to demonstrate method overriding. 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 "Problem with code to demonstrate method overriding." Watch "Problem with code to demonstrate method overriding." New topic
Author

Problem with code to demonstrate method overriding.

Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Greetings everyone,
I'm currently teaching a Java class and I wrote a program to demonstrate overriding and overloading and the
part of the program that demonstrates overriding doesn't just work, embarassingly. It looks so correct to me.
Can anyone see what's wrong?
Program listing:

---------------------------------------------------------------------------------------------------

The output:
String s version of method()
String s version of method()
both programs were in different source files in the same directory.


SCJP
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

String Method1() from the OverLoadingMethods class should not be capitalized. It should be spelled with a little 'm' ( method1() ). Since the only method1 your overriding class has is in it's super class due to the spelling mistake, it will call the superclass's method1(). If it is more than a spelling mistake repost here again.
Jamie
Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Many thanks. We got the answer before the class was over and we are all happy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with code to demonstrate method overriding.
 
Similar Threads
SCJP questions
override or overload?
overriding
Question regarding covariant returns
Dynamic polymorphism and Overriding