• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface  RSS feed

 
Santosh Kumar Nayak
Ranch Hand
Posts: 193
Eclipse IDE IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case an Interface has a protected modifier for a method then what are the modifiers allowed to the derived class ?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santosh Kumar Nayak wrote:In case an Interface has a protected modifier for a method then what are the modifiers allowed to the derived class ?


Have you tried creating an interface with a protected modifier for a method? Did it work?

Henry
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Have you tried creating an interface with a protected modifier for a method? Did it work?

More interesting part is when you define primitive var in Interface - it is allowed, reachable by implementors but can NOT be modified.
Why compiler says it's 'final', when it's not?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
surlac surlacovich wrote:
More interesting part is when you define primitive var in Interface - it is allowed, reachable by implementors but can NOT be modified.
Why compiler says it's 'final', when it's not?


The compiler says that it is final because it is... "variables" declared in interfaces, are more meant to be constants than variables. In fact, the java language specification calls it a constant declaration -- not a variable declaration.

http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.3

Henry
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
The compiler says that it is final because it is... "variables" declared in interfaces, are more meant to be constants than variables. In fact, the java language specification calls it a constant declaration -- not a variable declaration.

http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.3

Henry

Thanks a lot Henry for You reply, very helpful as usual
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!