About Question enthuware.ocpjp.v11.2.3318 :

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

Moderator: admin

Post Reply
asi-aal
Posts: 10
Joined: Wed Nov 23, 2022 3:40 am
Contact:

About Question enthuware.ocpjp.v11.2.3318 :

Post by asi-aal »

The last option is a bit confusing


Runnable r = ()-> 1+2; would not compile but someMethod() (which returns an int) compiles? How could you explain this?

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

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

Post by admin »

1+2 is a syntactically illegal statement, while a method call is not.
Please go through this article carefully to understand how a lambda expression is perceived by the compiler:
https://enthuware.com/oca-ocp-java-cert ... interfaces
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 83 guests