posted 10 years ago
Hi Naveen Yadav,
In Above Code, First Precedence goes to the "ga.getI()" as () operator has higher precedence, so it will call the getI() method of Arabik before printing anything,
1) we have in getI() method of Arabik which will print "Sub" First
2) later above code i.e., line 1 starts print the content from left to right as + operator has left to right associativity, so ga.i will print the value of "1" , because you can't override the instance variable in inheritance.
3) Then It prints ","
4) Then returned value of ga.getI() method of Arabik, which is "2"
so you are getting Sub1 , 2
Please correct me if i am wrong anywhere and i am much interested to see how other people are thinking and describing the answer, which will help us to understand more about the topic
Thanks & Regards
S.Sathiya