A

Admin • 830.13K Points
Coach

Q. What will be the output for the below code?
public interface TestInf{
int i =10;
}

public class Test{
public static void main(String... args){
TestInf.i=12;
System.out.println(TestInf.i);
}
}

  • (A) Compile with error
  • (B) 10
  • (C) 12
  • (D) 12 D. Runtime Exception
  • Correct Answer - Option(A)
  • Views: 9
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
All the variables declared in interface is implicitly static and final , therefore can't change the value.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.