This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java reference types  RSS feed

 
Adi Sharma
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot
 
Campbell Ritchie
Sheriff
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Peter Granstrom
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your answer,
it helped me
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!