This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface

 
Moon Winter
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 356
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Metal Zhang
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

------------------
Java lover from hell!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic