Question 6. An Interface can never be private or protected. Answers True False The answer given is False. Can anyone give out an example which an interface is private or protected (including inner interface). Thanks! Moon
Muhammad Farooq
Ranch Hand
Joined: May 08, 2001
Posts: 356
posted
0
Only an interface declared in a class can be declared private or protected, thats why the answer is false. The word "NEVER" is used in the question. HTH --Farooq e.g. =============================================================== class InterfaceTest{ private interface privateinterface{} protected interface protectedinterface{} } =============================================================== [This message has been edited by Muhammad Farooq (edited September 02, 2001).]
Muhammad Farooq<br />Sun Certified Programmer for Java 2 Platform<br />Oracle8i Certified Professional Database Administrator
Metal Zhang
Ranch Hand
Joined: Aug 05, 2001
Posts: 52
posted
0
Please try to compile and run this code:
The output is: 10 I think it is a good example to prove the question.And if you try to compile this code:
The compiler will complain: Test8.java:1: The type type Foo can't be private. Package members are always accessible wi thin the current package. private interface Foo{ ^ 1 error