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

Execution

 
sandhi mridul
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,



Output is :30,30,10,20

What is going on in the program?
How the control is getting transfer in the program?
Please help me.

Thanks
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objects 'o1' and 'o2' both refer to an object of type 'C', so m1() in class 'C' is invoked twice, because overridden instance methods invocation is determined at Runtime based on the object type.

Variable access is determined at Compile time based on the reference type.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic