This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

what about Interface Type

 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
My dout is .... The compiler checks the class of the reference type -not the object type -to see if you can call a method using that reference .
so what about the interfece reference type?
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
raj chiru wrote:Hi..
My dout is .... The compiler checks the class of the reference type -not the object type -to see if you can call a method using that reference .
so what about the interfece reference type?


Raj,
Same strategy for interface as well ( as with class)
 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
balu..Thanks for reply

But interfaces are abstract
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Raj,

Yes , Abstract classes cannot be instantiated , but it can call its own methods using its subclass objects. (polymorphism comes to picture here.)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic