Fundamental Coding Skills Flashcards
7 cards from real Mettl practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Fundamental Coding Skills flashcards as text
Which keyword is used to exit a loop prematurely in most languages?
Answer: break
The `break` statement immediately terminates the innermost enclosing loop.
What is a recursive function?
Answer: A function that calls itself
A recursive function is one that calls itself, usually with a smaller input, until reaching a base case.
Which of the following is NOT a primitive data type in Java?
Answer: String
String is an object (reference type) in Java, while int, boolean, and double are primitive types.
What does `&&` represent in most C-style programming languages?
Answer: Logical AND
`&&` is the logical AND operator, returning true only when both operands are true.
Which sorting algorithm has an average time complexity of O(n log n)?
Answer: Merge Sort
Merge Sort consistently achieves O(n log n) average and worst-case time complexity by dividing and merging.
What is the purpose of a `return` statement in a function?
Answer: To send a value back to the caller
The `return` statement exits the function and optionally passes a value back to wherever the function was called.
In Python, what is the result of `len('hello')`?
Answer: 5
The string 'hello' contains 5 characters (h, e, l, l, o), so `len('hello')` returns 5.