jqplusv7 - Class Design Question 3

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
wandile177@gmail.com
Posts: 2
Joined: Fri Sep 19, 2014 3:41 am
Contact:

jqplusv7 - Class Design Question 3

Post 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.

admin
Site Admin
Posts: 9174
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: jqplusv7 - Class Design Question 3

Post by admin »

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.

wandile177@gmail.com
Posts: 2
Joined: Fri Sep 19, 2014 3:41 am
Contact:

Re: jqplusv7 - Class Design Question 3

Post by wandile177@gmail.com »

Hahaha it is actually very funny that I did not notice that. Thank you sir.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests