troubleshooting Question

Java Inheritance super keyword use

Avatar of chima
chima asked on
8 Comments1 Solution277 ViewsLast Modified:
Without showing the entire code, I hope to explain what I'm expecting to get answered.
I have initialized a and b, in the parent class.  In the sub class "classB" it is extended by classA.
In classB, as shown below, I can re-initialize a and b (at least I think it is the a and b from classA), if they are from classA.
 I would not want to re-initialize a and b in classB, but I have no choice (error occurs if I do not initialize them).  what I would like to see from super.m3(), in the println statement; are the values given to a and b within the parent class (classA).
Might you know how to do this;
class classB extends classA{
		public int c;  public int d;
		public void m3(){
			System.out.println("This is classB super m3" +  " " + "a & b are initilized in ca: " + a + b + c + d + "\n");		


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros