Correct.Rinkesh wrote:this(z,z) will call public B(int x,int y) which has super(x) which further calls public A(int x),Am I right?
About Question enthuware.ocajp.i.v7.2.1355 :
Moderator: admin
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1355 :
If you like our products and services, please help us by posting your review here.
-
- Posts: 16
- Joined: Thu Mar 19, 2020 2:27 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1355 :
question says "which of the constructors shown in the options can be added to class B without causing a compilation to fail?" , which means even after adding the 2 constructors from options , the program should compile fine right? but if we add option c and E constructors ,it will not compile because both methods have same name and type . please clarify.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1355 :
No, you have to select 2 options. So, it is clear that you cannot have both of them at the same time otherwise, as you said, it will not compile!
Even from the options it is clear that if you add any two options in the class together, it will not compile, while the problem statement is asking you to ensure success in compilation. So, they have to be inserted independent of each other.
Even from the options it is clear that if you add any two options in the class together, it will not compile, while the problem statement is asking you to ensure success in compilation. So, they have to be inserted independent of each other.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Sat Aug 22, 2020 1:03 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1355 :
Quick question, how are classes A and B compiling with the absense of a no-args constructor?
Because both classes declare constructors with arguments is it not necessary to declare a no-args one as it won't be done automatically?
Apologies if this is obvious but I've read the below answers and the explanation and this particular point still isn't clicking for me.
Because both classes declare constructors with arguments is it not necessary to declare a no-args one as it won't be done automatically?
Apologies if this is obvious but I've read the below answers and the explanation and this particular point still isn't clicking for me.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1355 :
It is not necessary for a class to have a no args constructor. A class needs a no args constructor only if you want to instantiate it without any arguments.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Google [Bot] and 31 guests