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.
jqplusv7 - Class Design Question 3
Moderator: admin
-
- Posts: 2
- Joined: Fri Sep 19, 2014 3:41 am
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: jqplusv7 - Class Design Question 3
You are calling super(m); in the subclass constructor but you have commented out //public SuperClass(int m) { } in the superclass.
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Fri Sep 19, 2014 3:41 am
- Contact:
Re: jqplusv7 - Class Design Question 3
Hahaha it is actually very funny that I did not notice that. Thank you sir.
Who is online
Users browsing this forum: No registered users and 33 guests