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
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
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 →
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.