ExamVeda
Login
Home
Interfaces and Abstract Classes
?

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);
      }
}

Answer & Solution
Correct Answer: Option A

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

Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Sailaja Vishnubhatla
Sailaja Vishnubhatla 6 years ago
But class test did not implement interface testinf.