Page 1 of 1

jqplusv7 - Class Design Question 3

Posted: Fri Sep 19, 2014 3:46 am
by wandile177@gmail.com
I have tried running a program like this and it does not compile.

public class SuperClass {

public SuperClass() { }
//public SuperClass(int m) { }

public class SubClass extends SuperClass {

int i, j, k;
public SubClass(int m, int n) { i = m; j = m;}
public SubClass(int m) { super(m); }
}

}

Kindly explain why it does not run.

My answer was that a constructor is not needed in the main class.

Re: jqplusv7 - Class Design Question 3

Posted: Fri Sep 19, 2014 10:19 am
by admin
You are calling super(m); in the subclass constructor but you have commented out //public SuperClass(int m) { } in the superclass.

Re: jqplusv7 - Class Design Question 3

Posted: Wed Sep 24, 2014 8:49 am
by wandile177@gmail.com
Hahaha it is actually very funny that I did not notice that. Thank you sir.