aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question about class and interface Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Question about class and interface" Watch "Question about class and interface" New topic
Author

Question about class and interface

Scott Xia
Greenhorn

Joined: Aug 20, 2001
Posts: 20
question under:
interface Foo{
int k=0;
}
public class Test implements Foo{
public static void main(String args[]){
int i;
Test test=new Test();
i=test.k;
i=Test.k;
i=Foo.k;
}
}
Which statement is true?
A. Compilation succeeds
B. An error at line 2 causes compilation to fail
C. An error at line 9 causes compilation to fail
D. An error at line 10 causes compilation to fail
E. An error at line 11 causes compilation to fail
the answer is A
i do not understand why ?
Panday Manako
Ranch Hand

Joined: Mar 29, 2001
Posts: 80
fields in interfaces are automatically static and final
Scott Xia
Greenhorn

Joined: Aug 20, 2001
Posts: 20
thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about class and interface
 
Similar Threads
Strange question
interface doubt
in Interface the instance variables are final, right?So what happens in this code?
Interface qustion
A static class ?