Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method invocation

 
payal bansal
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i run this program, o/p is String Version. Could anyone give me the reason for this? Why Object version not get printed. I do want to know the reason for this o/p. Please help me!
1. public class Test {
2. public void method(Object o) {
3. System.out.println("Object Version");
4. }
5. public void method(String s) {
6. System.out.println("String Version");
7. }
8. public static void main(String args[]) {
9. Test test = new Test();
10. test.method(null);
11. }
12. }
 
Art Metzer
Ranch Hand
Posts: 241
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic