Discussion Forum : Interfaces And Abstract Classes
Question - 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);
}
}
Options:
A .  Compile with error
B .  10
C .  12
D .  Runtime Exception
E .  None of these
Answer: Option A
All the variables declared in interface is implicitly static and final , therefore can't change the value.

Was this answer helpful ?
Next Question
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *