aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inheritance" Watch "inheritance" New topic
Author

inheritance

amrit singh
Ranch Hand

Joined: Nov 03, 2000
Posts: 42
Hi!!!
JLS says
"constructors and static initializers are not memebers and are
not inherited by the subclasses"
but i am confused
if we declare a static protected class variable
it is inherited by all sublcasses
class P{
static protected int i;
}
i.e
i will be inherited by all sublasses of P.
do i am missing something
thanxxxxx
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
The code you have given illustrates a static variable declaration and not a static initializer. Static/instance initializers are blocks of code that appears in the class context without any name.
Here is an example I pulled out from my code repository. Since the code is self documentary I will not deliberate much about what is what. This little program also demonstrates the order of invocation of initializers and constructors. Give it a swirl!

Ajith

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inheritance
 
Similar Threads
Doubts on Protected Members
Protected members inheritance
Old Chestnut: Protected Access
Visibility limits of protected access Specifier