Courseiva
Working with Streams and Lambda ExpressionshardMultiple ChoiceObjective-mapped

1Z0-829 Working with Streams and Lambda Expressions Practice Question

Which of the following lambda expressions is syntactically invalid?

⚠ Common exam trap

It's easy for candidates to confuse the syntax of expression lambdas with block lambdas, mistakenly thinking `return` can be used without braces, or they forget that a single expression without `return` is implicitly returned.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

(a, b) -> return a + b;

Syntactically invalid because in a lambda expression, the `return` keyword is only allowed inside a block body (with braces). When using an expression body (no braces), the `return` keyword must be omitted, and the expression itself is implicitly returned. Option C incorrectly uses `return` without braces, which is a syntax error.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • () -> {return 42;}

    Why it's wrong here

    Valid. Block body with return statement.

  • (a, b) -> a + b

    Why it's wrong here

    Valid. Type inference with single expression.

  • (a, b) -> return a + b;

    Why this is correct

    Invalid. 'return' keyword requires a block body (curly braces).

  • (int a, int b) -> a + b

    Why it's wrong here

    Valid. Explicit parameter types with single expression body.

  • (a) -> a * 2

    Why it's wrong here

    Valid. Single parameter with expression body.

Quick reference

Cloud Service Model Comparison

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.