wood burning stoves 2.0*
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
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with code to demonstrate method overriding.