Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Answers

Question 1: Variable Declarations

Correct Answer: C) 40

Question 2: Function Definition

Correct Answer: C) Multiplies two numbers

Question 3: Immutable List Operations

Correct Answer: A) List(2, 4, 6, 8, 10)

Question 4: Pattern Matching

Correct Answer: A) World

Question 5: Variable Mutability

Correct Answer: B) var

Question 6: Scala's Type Inference

Correct Answer: C) Omit the type of a variable when it is declared

Question 7: Function Declarations

Correct Answer: A) def sum(x: Int, y: Int): Int = { return x + y }

Question 8: Using a while Loop

Correct Answer: B) 15

Question 9: Iterating with for Loop

Correct Answer: B) 24

Question 10: Nested for Loops

Correct Answer: A) (1,1) (1,2)
(2,1) (2,2)
(3,1) (3,2)

Question 11: Basic if-else Logic

Correct Answer: A) You can vote.
Can vote: true

Question 12: Nested if-else with Logical Operators

Correct Answer: A) You can drive.

Question 13: if-else with Compound Conditions

Correct Answer: A) It's a good day for a walk.

Question 14: Complex if-else with Function Calls

Correct Answer: C) Not eligible: Too young

Question 15: Basic Pattern Matching

Correct Answer: C) Three

Question 16: Defining and Calling a Simple Function

Correct Answer: B) Hello, Alice!