About Question enthuware.ocajp.i.v7.2.1216 :
Posted: Tue May 10, 2016 8:12 pm
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.
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.