About Question enthuware.ocajp.i.v7.2.1355 :

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

Moderator: admin

Post Reply
admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1355 :

Post by admin »

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?
Correct.
If you like our products and services, please help us by posting your review here.

swarna pakeer
Posts: 16
Joined: Thu Mar 19, 2020 2:27 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1355 :

Post by swarna pakeer »

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.

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

Re: About Question enthuware.ocajp.i.v7.2.1355 :

Post by admin »

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.
If you like our products and services, please help us by posting your review here.

Ph03nix89
Posts: 1
Joined: Sat Aug 22, 2020 1:03 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1355 :

Post by Ph03nix89 »

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.

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

Re: About Question enthuware.ocajp.i.v7.2.1355 :

Post by admin »

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.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 31 guests