System.out.println(finalStr); //above line will results compile error due to ambiguous
There's no ambiguity in here. The line will not compile because you are trying to access a non-static variable from static context.
Also in Sweta's example there is no ambiguity. Also �220.127.116.11 has nothing to do with it.
As s1 in I is implicity public static final (as it is a constant), how come A modifies it ?
I guess, Sweta is mixing up the two different finals:
A final method cannot be overridden. A final variable cannot be reassigned. But in a class that inherites the variable, you can define a new variable with the same name.
In Sweta's example the situation is even more complicated: Variable s1 in interface I is implicitely static. So even though you don't read the "static" keyword in the code, it is there. Along with final.
In the implementing class, you have a non-static variable with the same name. Therefore, the static variable cannot be assigned as A.s1. Would be referencing non-static from static ... the classic fault. But it can still be refernced through the interface, thus
no needs for apologies here. The code from Sweta is in the category "looks easy, is tricky". I really want to know, how many cowboys make mistakes in trying to access a non-static variable from a static context in the real exam. Say, after properly answering questions for over an hour...
all events occur in real time
Can you smell this for me? I think this tiny ad smells like blueberry pie!