File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with code to demonstrate method overriding.

 
Femi Alla
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic