The int x and int y that were declared and initialized within the main() method are local fields. And since the local fields have exactly same names as the instance fields (i.e. the int x and int y that where declared after the class definition), then the local fields shadows the instance fields. Accordingly, the println() method takes the x and y of the main() method.
The println() method can print the instance fields in case we use different names of the local variables x and y.
# javac Test18.java
# java Test18
3 5
Answer B:
The int x and int y that were declared and initialized within the main() method are local fields. And since the local fields have exactly same names as the instance fields (i.e. the int x and int y that where declared after the class definition), then the local fields shadows the instance fields. Accordingly, the println() method takes the x and y of the main() method.
The println() method can print the instance fields in case we use different names of the local variables x and y.