Puspender Tanwar wrote:output is correct but I am confuse in the way is it printed. At //line 1 b.h is called first so 4 should print firstly, but the method statement is printed firstly, why is it so ?
Key point is, because method call "()" has higher precedence than member access "."
1. It invokes method first - goes inside the method, executes print statement and (1)prints"Beta 44", returns value "44", and goes out of method.
2. Executes print statement from left to right - (2)prints evaluated member variable value "4", and then (3)prints returned value from method "44".
Not sure what's so funny, but, have you understood what Jeanne told you and myself?
Enthuware Software Support
posted 3 years ago
Puspender, if you post a question from a mock exam/book on Code Ranch, you need to quote the source from where you got it.
Since I recognize that the question is from our material, I would like to suggest you to click on the "Discuss" button (if you are using our exam simulator) or click on the Question Id (if you are using Kindle eBook) to see a discussion on that particular question. In this case, it will take you to this page: http://enthuware.com/forum/viewtopic.php?f=2&t=2075