Drag steps to the numbered slots on the right, or tap a step then tap a slot.
1Z0-829 Practice Question: Handling Date, Time, Text, Numeric and Boolean Values
Arrange the steps to use a lambda expression to sort a list of strings by length.
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
Start by creating a list of strings. Then write a lambda expression that uses Integer.compare to compare string lengths. Then pass the lambda to the Collections.sort method. Finally, print the sorted list.
Comparator is a functional interface; lambda provides concise implementation. Integer.compare() handles comparison safely.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Start by creating a list of strings. Then write a lambda expression that uses Integer.compare to compare string lengths. Then pass the lambda to the Collections.sort method. Finally, print the sorted list.
Why this is correct
This is the correct order because you first need the data (list), then define the comparison logic (lambda), then apply it via sort, and then optionally output the result.
- ✗
Start by writing a lambda expression that uses Integer.compare to compare string lengths. Then create a list of strings. Then pass the lambda to the Collections.sort method. Finally, print the sorted list.
Why it's wrong here
This is incorrect because the lambda is defined before the list exists. While it's syntactically allowed, logically you need the list first to know what to sort.
- ✗
Start by creating a list of strings. Then pass the lambda to the Collections.sort method. Then write a lambda expression that uses Integer.compare to compare string lengths. Finally, print the sorted list.
Why it's wrong here
This is incorrect because you cannot pass a lambda to sort before it has been written. The lambda must be defined before it can be used.
- ✗
Start by creating a list of strings. Then write a lambda expression that uses Integer.compare to compare string lengths. Then print the sorted list. Finally, pass the lambda to the Collections.sort method.
Why it's wrong here
This is incorrect because printing the list before sorting would output the unsorted list. The sort must occur before any output that depends on ordering.
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
This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.