Questions is taken from
SCJP Exam for J2SE 5 from Paul Sanghera
Consider the following source file:
1. interface Animal {
2. void saySomething();
3. }
4. class farm {
5. void setName(
String name){};
6. }
7. // insert code here
8. public class
Cow implements Pasture {
9. public void graze() { }
10. void saySomething(){}
11.}
Which of the following code lines inserted independently at line 7 will make this source file compile?
A. interface Pasture {void graze();}
B. interface Pasture {void graze(){}}
C. interface Pasture extends Animal{void graze();}
D. interface Pasture extends Animal{void saySomething(){}}
E. interface Pasture implements Animal{void graze();}
I thought the answer is only A but the answer sheet says that A and C.
But, I thought that if we make saySomething default access in the subclass it is not allowed am I wrong because interface methods are public ?
we cannot convert public to default access, is it a typo like that ?
what do you think ?
![](https://coderanch.com/images/smilies/jr-eek.gif)