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".