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

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

Moderator: admin

Post Reply
ETS User

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

Post by ETS User »

Call a constructor of the superclass from the subclass doesn't mean that it will costruct an instance of the subclass. CALL is written. I can call a constructor of the superclass in the subclass (maybe inside a method or a constructor) only if it is declared public or protected, so the answer is true.

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

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

Post by admin »

ETS User wrote:Call a constructor of the superclass from the subclass doesn't mean that it will costruct an instance of the subclass. CALL is written. I can call a constructor of the superclass in the subclass (maybe inside a method or a constructor) only if it is declared public or protected, so the answer is true.
That is why the explanation says that most of the statement is correct. Only the part where it says "because only those are inherited", is wrong. Constructors are never inherited.

HTH,
Paul.

muttley
Posts: 19
Joined: Thu Feb 28, 2013 9:47 am
Contact:

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

Post by muttley »

I agree with the answer but I am not agree with the explanation.
The affirmation "constructors are NEVER (whether public or otherwise) inherited" is wrong.
Look that:

Code: Select all

public class Parent{
 public Parent(){
	System.out.println("Parent Class");
 }
}

Code: Select all

public class Child extends Parent{
}
When this code is run in a main class the code print "Parent Class", it means that the parent constructor was inherited.
What do you think?

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

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

Post by admin »

The output just means that parent constructor was called. It does not prove that it was inherited!

The subclass's constructor calls parent class's constructor. That is why you see the output.

Guest

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

Post by Guest »

By the way:

class A{
public A(int i){}
private A(int i, String s){}
}

class B extends A{
public B(int i){ super(i);} // CORRECT!
public B(int i){ super(i, "s");} // INCORRECT!
}

....

new B(10); // INCORRECT

Too ambiguous question.

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

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

Post by admin »

Not sure what is your point. The problem statement as such is quite unambiguous.
-Paul.

insider
Posts: 29
Joined: Wed Apr 17, 2013 9:22 am
Contact:

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

Post by insider »

It's true that the question appears to be correct. However, it's not about Java. It's about how to phrase the question because with question stated as it is now, it's a word-catching game. If the real exam contains such traps then let it be. If not, you need to rephrase the question. You have lots of opportunities for qualitative testing based on actual Java knowledge only, other EW questions clearly show that.

kecker
Posts: 18
Joined: Mon Jan 13, 2014 5:39 am
Contact:

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

Post by kecker »

Agreed, both the question and the explanation themselves are VERY poorly worded.

Especially the explanation of "To invoke A's constructor you have to do

class B extends A{
public B(int i){ super(i); }
}"

A call to super() is implicitly added as the first line of the constructor. In fact your answer to question #25 says exactly that. Basically those two answers contradict each other.

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

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

Post by admin »

kecker wrote:Agreed, both the question and the explanation themselves are VERY poorly worded.

Especially the explanation of "To invoke A's constructor you have to do

class B extends A{
public B(int i){ super(i); }
}"

A call to super() is implicitly added as the first line of the constructor. In fact your answer to question #25 says exactly that. Basically those two answers contradict each other.
The explanation is just providing an example to show that constructors are not inherited at all. In this case, class A does not have a no-args constructor, so you have to explicitly call super(i) as shown above, in B's constructor. That is why the statement, "To invoke A's constructor you have to do...." is correct. There is no other way to invoke A's constructor.

Further, an implicit call to super() (wherever applicable) is still a call to the super class's constructor. That does not mean that the super class's constructor is inherited by the subclass.

So I am not sure what contradiction do you see in the answers.

Regarding the problem statement, please do let us know which part do you think is poorly worded so that we can improve it. As such the problem statement is clearly false because it says that constructors are inherited, which is not true.

HTH,
Paul.

Shortrope
Posts: 15
Joined: Sun Jun 01, 2014 8:27 pm
Contact:

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

Post by Shortrope »

Thanks for the clarification Paul. You are correct. I think this discussion has a second issue.

As a veteran of many certification tests, I can tell you that the way to study for a certification test is different than the way you study to actually implement, optimize and trouble shoot the technology in a production environment.

The frustrating reality is, Certification tests require the skill to decipher the wording of the questions. You will receive questions that seem to be gray areas and they want the "Best answer"! You must be on the look-out for the gotcha word/phrase! Also very important is learning to save time by recognizing the 'fluff' text and code that does not directly apply to the actual question/answer.

Practice tests force you to practice these test taking skills. I always get frustrated and angry when taking the practice tests but realize their value in the real exam.

My experience is with Novell, Microsoft and Cisco exams. I have not taken an Oracle exam, yet, but my guess is they are similar animals.

Good luck

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests