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 java reference types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java reference types" Watch "java reference types" New topic
Author

java reference types

Adi Sharma
Ranch Hand

Joined: May 18, 2009
Posts: 33
I am preparing for SCJP and was reading the :

" method invocations allowed by the compiler are based solely on
the declared type of the reference, regardless of the object type. "

could anyone explain what it means ???

Thanks
Aditya Sharma
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38057
    
  22
It means that when you declare

Foo fff;
. . .
fff = new FooFoo(123, "abc");
. . .
fff.baa();

the compiler will only allow that baa() call if the Foo class has a method called baa. If the Foo class hasn't and the FooFoo class has, then the compiler will not allow that code to be compiled.
Adi Sharma
Ranch Hand

Joined: May 18, 2009
Posts: 33
Thanks a lot
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38057
    
  22
You're welcome
Peter Granstrom
Greenhorn

Joined: Jun 08, 2009
Posts: 10
thank you for your answer,
it helped me
 
jQuery in Action, 2nd edition
 
subject: java reference types
 
Similar Threads
overLoading
classCastException
arrays & final
About type and class attribute of jsp usebean
reference problem