| Author |
A minor confusion about constants..
|
Milind Chaudhary
Greenhorn
Joined: Jul 09, 2010
Posts: 20
|
|
When I was reading interfaces, it was in K&B that interface constants are public static final implicitly.
Normal constants are final implicitly and they are not public static...
Just tell me am I correct?
And also answer to the fact that why a class cannot be declared protected?
|
 |
Abimaran Kugathasan
Ranch Hand
Joined: Nov 04, 2009
Posts: 2066
|
|
Milind Chaudhary wrote:When I was reading interfaces, it was in K&B that interface constants are public static final implicitly.
Normal constants are final implicitly and they are not public static...
Just tell me am I correct?
constant are final variables, If you defined your own final variable, you should defined it with final key word. For interface, whether you defined the variable with or without any of the modifier(public, static, final), those variables are implicitly public static final. For others, you should defined with the keyword final.
Milind Chaudhary wrote:
And also answer to the fact that why a class cannot be declared protected?
What's the purpose of making a class protected?
|
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
|
 |
Milind Chaudhary
Greenhorn
Joined: Jul 09, 2010
Posts: 20
|
|
|
Thanks for your answer, but I want to know what is a class's visibility when it is protected and what's the harm in making it protected..How does a protected class behave? Please elaborate.. though this is only for my knowledge and not for exam..
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
protected member of class A can be accessed from class B[which is the subclass of A] even if B is in different package. here notice a point *class A must be public to visible in other packages*. so it doesn't make a sense to declare class as protected
hth
|
 |
Milind Chaudhary
Greenhorn
Joined: Jul 09, 2010
Posts: 20
|
|
|
Thanks a lot for your answer.. it cleared my doubt..
|
 |
 |
|
|
subject: A minor confusion about constants..
|
|
|