To answer this question, let's go through each line to understand if it generates a compile-time error:
1) void f1();
- This line does not generate a compile-time error because the default access modifier for interface methods is public
.
2) public void f2();
- This line does not generate a compile-time error because the access modifier public
is allowed for interface methods.
3) protected void f3();
- This line generates a compile-time error because the access modifier protected
is not allowed for interface methods. Interface methods can only have public
access modifier.
4) private void f4();
- This line generates a compile-time error because the access modifier private
is not allowed for interface methods. Interface methods can only have public
access modifier.
Therefore, the correct answer is option D) compile time error at lines 3,4.