This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 38519
    
  23
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: 38519
    
  23
You're welcome
Peter Granstrom
Greenhorn

Joined: Jun 08, 2009
Posts: 10
thank you for your answer,
it helped me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java reference types