You are here:

Java/Static and inheritance

Advertisement


Question
do static method and static data takes part in inheritance? if not how it is possible to access static method or data of base class  by derived class object is ok in JAVA, where error in c++.does c++ behave differently with static .plz explain?

Answer
No, static methods and data aren't part of inheritance, although you can call static methods without qualifying the class if it is in a subclass. You can access static data in subclasses the same way a any other class access it. I.e. ClassName.method().

This is basically the same way it work as in C++.

Java

All Answers


Answers by Expert:


Ask Experts

Volunteer


Artemus Harper

Expertise

I have a Masters in computer science. I can answer questions on core J2SE, swing and graphics. Please no questions about JSP or J2ME.

Experience

I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection. Some experience in bio-informatics. Basics in c++ and c#

Organizations
Washington State University

Education/Credentials
MS in Computer Science from Washington State University and a BS in Mathematics and Computer Science from Central Washington University.

©2016 About.com. All rights reserved.