About Question enthuware.ocpjp.v11.2.3641 :

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

Moderator: admin

Post Reply
adrianjara
Posts: 2
Joined: Fri May 03, 2024 6:41 am
Contact:

About Question enthuware.ocpjp.v11.2.3641 :

Post by adrianjara »

Hello

I know it's not within the context of the question, but I wanted to write to find out if I'm wrong or not.

In the following code, it appears that the lambda expression is typed incorrectly, is this correct?

Code: Select all

public void invokeService(String srvname, String host, int port){
     ...
     Socket socket = null;
     try{
        AccessController.doPrivileged( ( PrivilegedExceptionAction<Void> ) ()->
               socket = new Socket(host, port);
               return null;
     }
     ...
}
Both lines after the lamda expression belong to the lamda expression? So shouldn't I have a key?

And if this were not the case, if only the first line belongs to the lambda, which I do not think is the case, then the ; at the end of the expression it would not be bad.

Thanks in advance for responding

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

Re: About Question enthuware.ocpjp.v11.2.3641 :

Post by admin »

Yes, an opening and closing brace should be there so that both the line become part of the lambda.

>Both lines after the lamda expression belong to the lamda expression?
Yes.

>So shouldn't I have a key?
Not sure what you mean.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests