1. What will be the output of the program? interface Foo141 { int k = 0; / Line 3 / } public class Test141 implements Foo141 { public static void main(String args[]) { int i; Test141 test141 = new Test141(); i = test141.k; / Line 11 / i = Test141.k; i = Foo141.k; } }
Ask Your Doubts Here
Comments
By: guest on 02 Jun 2017 01.26 am
The variable k on line 3 is an interface constant, it is implicitly public, static, and final. Static variables can be referenced in two ways: Via a reference to any instance of the class (line 11) Via the class name (line 12).