Can someone tell me why answer C is not correct? Thanks.
[Bagnall, ExamSim]
I not only use all the brains that I have, but all that I can borrow. [Laurence J. Peter]
Reshma Shanbhag
Ranch Hand
Joined: Sep 17, 2002
Posts: 202
posted
0
Karin, Any member variables declared within an Interface are Implicitly public, static and final. The complier complains when you dont initialize the final variables. Hence in option (c) when you declare 'int c' it is equivalent to 'public static final int c' and since it is not initialized complier will complain. Hence option 'c' is not right. Hope this helped you Reshma
SCJP 1.4, SCWCD 1.4
Ravi Anamalay
Ranch Hand
Joined: Apr 15, 2003
Posts: 38
posted
0
So is the answer to the question A & E ?
with kind regards,<br />Ravi
Karin Paola Illuminate
Ranch Hand
Joined: Oct 18, 2002
Posts: 109
posted
0
Thanks. So, A. public interface A {int a();} Ok. The methods in an interface are all abstract. B. public interface B implements A {} Not Ok. Interfaces can only extend other interfaces (not implement). C. interface C {int a;} Not Ok. D. private interface D {} Not Ok. E. abstract interface E {} Ok. An interface is already abstract implicitly, but can be declared abstract. So, interfaces may not declare variables unless they are initialized? I believe that is also true for classes. Classes may not declare variables as final unless they are initialized. But, that doesn't seem to be true for "local variables or automatic variables". Am I correct?