About Question enthuware.ocpjp.v8.2.1135 :

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

Moderator: admin

Post Reply
RAZER-KIEV
Posts: 17
Joined: Thu Oct 01, 2015 4:06 pm
Contact:

About Question enthuware.ocpjp.v8.2.1135 :

Post by RAZER-KIEV »

How it can correctly instantiate "TestInner" object from Line 1 if the code never calls myOuterMethod() ?

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

Re: About Question enthuware.ocpjp.v8.2.1135 :

Post by admin »

It is true that the code that is given with the question doesn't call myOuterMethod(). But that is not really required. It is a public method and it could be called from any other class.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

RAZER-KIEV
Posts: 17
Joined: Thu Oct 01, 2015 4:06 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1135 :

Post by RAZER-KIEV »

imho it looks like ambiguously.
1) There is no any information about other classes. So we have no any guaranty that it will be called from somewhere.
2) The existing and content of psvm method shows that there is not any "// lot of another code" so this is enough to think that this is completely content of psvm. So I can say that it is impossible to call myOuterMethod() from anywhere. Am I wrong?

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

Re: About Question enthuware.ocpjp.v8.2.1135 :

Post by admin »

The question is only talking about the lines of code that instantiate TestInner correctly. That is why it says, "instantiates" i.e. "Which of the following options correctly instantiates a TestInner object?" The given line of code in option 1 does correctly instantiate TestInner. Of course, instantiation will happen if it is invoked, but that is not part of the question. The question doesn't say if or whether TestInner is instantiated by the given code listing if the given program is compiled and executed. It doesn't even talk about running/executing the code. So from that perspective, even the main method is not executed.



HTH,
Paul.
If you like our products and services, please help us by posting your review here.

RAZER-KIEV
Posts: 17
Joined: Thu Oct 01, 2015 4:06 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1135 :

Post by RAZER-KIEV »

I can say that anything what located in myOuterMethod() will never be invoked, because we can observe psvm method which doesn't invokes it. As Application can't have one more psvm we can say that myOuterMethod never be called. If there was any other static method but not main, the options 1 and 5 would be correct. I understand that focus of this question was on other aspect, but we cant ignore that where is enough information to be sure that there are no places from where we can call myOuterMethod.

RAZER-KIEV
Posts: 17
Joined: Thu Oct 01, 2015 4:06 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1135 :

Post by RAZER-KIEV »

I was wrong !)
There can be more than one public static void main, in one application. So we can create another class with psvm where we can invoke "new TestOuter().myOuterMethod();" and it will work fine)
So option 1 and 5 are really correct.
Thanks for discussion)

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests