About Question enthuware.ocpjp.v8.2.1135 :
Moderator: admin
-
- Posts: 17
- Joined: Thu Oct 01, 2015 4:06 pm
- Contact:
About Question enthuware.ocpjp.v8.2.1135 :
How it can correctly instantiate "TestInner" object from Line 1 if the code never calls myOuterMethod() ?
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1135 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 17
- Joined: Thu Oct 01, 2015 4:06 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1135 :
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?
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?
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1135 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 17
- Joined: Thu Oct 01, 2015 4:06 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1135 :
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.
-
- Posts: 17
- Joined: Thu Oct 01, 2015 4:06 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1135 :
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)
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)
Who is online
Users browsing this forum: No registered users and 221 guests