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 Coding Skills flashcards as text
Which design pattern ensures only one instance of a class exists throughout an application?
Answer: Singleton
The Singleton pattern restricts instantiation to a single object and provides a global access point.
What is the output of the following C code snippet: `int x = 5; printf("%d", x++);`?
Answer: 5
Post-increment returns the original value before incrementing, so 5 is printed.
Which of the following best describes a deadlock in concurrent programming?
Answer: Two or more processes each waiting for the other to release a resource
Deadlock occurs when processes circularly wait for resources held by each other, halting all progress.
In object-oriented programming, what does 'encapsulation' mean?
Answer: Hiding internal state and exposing only necessary interfaces
Encapsulation bundles data and methods while restricting direct access to internal state.
What is the result of evaluating `5 & 3` in most programming languages (bitwise AND)?
Answer: 1
5 is 101 and 3 is 011 in binary; ANDing them yields 001, which equals 1.
Which HTTP method is idempotent and used to fully replace a resource?
Answer: PUT
PUT replaces the entire resource and is idempotent — calling it multiple times yields the same result.
In Python, what does `dict.get('key', 'default')` return when 'key' is absent?
Answer: 'default'
dict.get() returns the second argument as a fallback when the key does not exist.