“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
Campbell Ritchie wrote:
And always please tell us where such code comes from, so as to avoid copyright problems.
Campbell Ritchie wrote:Work out which order the methods are called in. You get as far as the first print statement and find the h field. Then what happens? Where is the value of h and what format is it stored in? Will the getH() call be executed before or after the + operator?
Campbell Ritchie wrote:Will the getH() call be executed before or after the + operator?
Pete Letkeman wrote:I recognize this, this is an Enthuware mock test question.
This has been discussed the following places by others.
Do any of the following posts help out?
https://coderanch.com/t/678147/certification/Enthuware https://coderanch.com/t/658010/certification/Explain-reason-output-Enthuware http://enthuware.com/forum/viewtopic.php?f=2&t=2075
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
Kelvin Okornoe wrote:Someone help me understand why?
Kelvin Okornoe wrote:b.h will print 4, Because variables are invoked using the reference type than the Object at runtime, and b.getH() will invoke the Beta version of the method at runtime. When it gets to which variable is printed in class Beta. Beta's variable h gets printed and returned.
Please correct me if am wrong!.
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|