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

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

Moderator: admin

Post Reply
astrobryan
Posts: 1
Joined: Tue May 10, 2016 8:00 pm
Contact:

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

Post by astrobryan »

I selected the option "A constructor can declare a return value." for this question, which was marked as incorrect.

Although I understand the context of the question, a constructor can be defined to declare a return value. When this happens, the constructor stops acting like a constructor and becomes a method that operates in the same way that any other class method. Although it would be a very strange programming practice to employ this, it is a true statement. I think the author of the question had a perspective that since a constructor which declares a return value would act like a class method, and not a constructor, it ceases to be a "constructor" in the literal sense.

I would expect the options for this question to be a bit more exact in "correct" vs. "incorrect", since the question only asks what statements are true. The statement "A constructor can declare a return value" is true, the implications of how the constructor-turned-method acts at runtime does not necessarily make the statement false.

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

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

Post by admin »

I understand what you are saying but I do not agree with it. As you mentioned, if you declare a return value for a constructor, it does not remain a constructor. Thus, even from a purely logical perspective, it is not a constructor that declares the return value. It is a method. Both the conditions - that something declares a return value and that something is a constructor - have to hold true at the same time for the given statement to be true.

HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests