File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Output of the program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Output of the program" Watch "Output of the program" New topic
Author

Output of the program

Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
What is the output for the comments(1),(2)?Why?




Thanks,
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

For comment 1 , this link may help ,

look this example


and for 2 comment , the equals checks for contents equality !

Hope this help


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
You are only able to access members of the declared type. In this case Object. When these members are invoked the implementation of the actual object is invoked.

Object has getClass method and the String implementation does not override it so the Object class's getClass method will be called.

Object has equals method but String class overrides the equals method so the string class's equals method is called.

String has length() method but Object does not have it so if you try to invoke the length() method on an reference of type Object compiler will complain.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Output of the program