• Post Reply Bookmark Topic Watch Topic
  • New Topic

What happens at compile time & run time, related to methods and variables?  RSS feed

 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried following code.

Ouput was
10
20.

What exactly happens, in this code?
Refrences and variables gets create at compile time and objects gets create at run time.
Because of this, when I said 't.i' value which is created at compile time is showing. Method 't.print()' calls at runtime so it is showing value of object Two class.
Is it right.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right, and one more thing, variables looks for the class of a reference and methods looks for the actual object hold by that reference !

Please correct me If I`m wrong !
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let me say something

variable can not be override,but method can be override
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by seetharaman venkatasamy:
let me say something

variable can not be override,but method can be override


Thanks , I missed out it completely ! That solves the whole problem !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!