In (int x, int y) -> x + y, what is 'x + y'?

Get ready for your Object‑Oriented Programming Test. Use flashcards and multiple-choice questions. Each question includes hints and explanations. Prepare for your exam today!

Multiple Choice

In (int x, int y) -> x + y, what is 'x + y'?

Explanation:
The thing after the parameter list and the arrow is the body of the lambda—the computation the lambda performs. Here, x and y are the inputs, and x + y is the operation that uses those inputs to produce a result. When the lambda runs, it evaluates x + y and returns that value. So x + y is the body of the lambda, the expression that defines what value gets returned. It’s not the parameters themselves, and it’s not a separate return type; the return value is whatever x + y evaluates to for the given inputs.

The thing after the parameter list and the arrow is the body of the lambda—the computation the lambda performs. Here, x and y are the inputs, and x + y is the operation that uses those inputs to produce a result. When the lambda runs, it evaluates x + y and returns that value. So x + y is the body of the lambda, the expression that defines what value gets returned. It’s not the parameters themselves, and it’s not a separate return type; the return value is whatever x + y evaluates to for the given inputs.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy