6 min read

Weekly Engineering Mastery Quiz (2026-03-02 to 2026-03-06)

A 20-question assessment covering fundamentals, implementation best practices, and advanced architecture insights from this week’s learning posts.

#Learning-log#Quiz#Assessment

Table of contents

  1. Fundamentals (Q1-Q5)
  2. Intermediate (Q6-Q12)
  3. Advanced (Q13-Q20)
  4. Answer Key & Explanations
  5. Sources & Further Reading

Fundamentals (Q1-Q5)

  1. Q1. Which Kotlin declaration creates an immutable variable using type inference?

    • A. val count = 10
    • B. var count: Int
    • C. val count: Int
    • D. var count = 10
  2. Q2. Which string template(s) correctly embed the value of name in “Hello, …!”?

    • A. “Hello, $name!”
    • B. “Hello, ${name}!”
    • C. Both A and B
    • D. “Hello, $(name)!”
  3. Q3. By default, what is the type of the literal 3.0 in Kotlin?

    • A. Float
    • B. Double
    • C. BigDecimal
    • D. Number
  4. Q4. Which Kotlin type represents a single UTF-16 code unit?

    • A. Char
    • B. String
    • C. Byte
    • D. Short
  5. Q5. Which declaration is a valid Boolean with an explicit type?

    • A. val done: Boolean = false
    • B. Boolean done = false
    • C. var done = “false”
    • D. val done: bool = false

Intermediate (Q6-Q12)

  1. Q6. Which is the recommended default approach to mutability for local variables?

    • A. Use var by default; switch to val if needed
    • B. Use val by default; use var only when reassignment is required
    • C. Always use var; the compiler will optimize
    • D. Always use val; reassign through reflection if needed
  2. Q7. Which assignment requires an explicit numeric conversion to compile?

    • A. val l: Long = 1L
    • B. val f: Float = 1.0
    • C. val b: Byte = 100
    • D. val d: Double = 1
  3. Q8. Which lateinit declaration is invalid?

    • A. lateinit var id: Int
    • B. lateinit var name: String
    • C. lateinit var ref: Any
    • D. lateinit var items: MutableList
  4. Q9. Which constant declaration is valid?

    • A. const val VERSION = “1.0”
    • B. const val now = System.currentTimeMillis()
    • C. const var FLAG = true
    • D. const val id: java.util.UUID = java.util.UUID.randomUUID()
  5. Q10. Given data class User(val name: String) and val user = User(“Mia”), which template prints “Hello, Mia” exactly?

    • A. “Hello, $user.name”
    • B. “Hello, ${user.name}”
    • C. “Hello, $(user.name)”
    • D. “Hello, ${user}.name”
  6. Q11. Which numeric literal is invalid in Kotlin?

    • A. 1_000_000
    • B. 0xFF_EC_DE_5E
    • C. 1_.0
    • D. 0b1010_1011
  7. Q12. Which operator checks structural equality in Kotlin?

    • A. =
    • B. ==
    • C. ===
    • D. ~=

Advanced (Q13-Q20)

  1. Q13. What is the inferred type of the declaration val x = null?

    • A. Any?
    • B. Nothing?
    • C. Unit
    • D. Null
  2. Q14. On the JVM, which choice minimizes allocations for a large numeric buffer?

    • A. Array
    • B. IntArray
    • C. MutableList
    • D. Array
  3. Q15. What is the inferred type of val r = 1 + 1L?

    • A. Int
    • B. Long
    • C. Number
    • D. Any
  4. Q16. On the JVM, what is the result of val i = Int.MAX_VALUE; val j = i + 1?

    • A. Throws ArithmeticException
    • B. j equals Int.MAX_VALUE (saturated)
    • C. j wraps to a negative value due to 32-bit overflow
    • D. Behavior is undefined
  5. Q17. Which statement about Char and Unicode is correct?

    • A. Kotlin Char stores a full Unicode code point
    • B. Kotlin Char is a 16-bit UTF-16 code unit; characters outside the BMP need a surrogate pair in a String
    • C. Kotlin Char is nullable by default
    • D. Kotlin Char stores ASCII only
  6. Q18. For public APIs under K2 inference, which practice best preserves binary/source stability?

    • A. Omit types and rely on inference everywhere
    • B. Always expose Number instead of concrete numeric types
    • C. Declare explicit types on public vals/vars and function return types
    • D. Use var for all public properties to keep them flexible
  7. Q19. When calling a Java method that may return null (platform type), what is the safest Kotlin declaration?

    • A. val s: String = javaApi.getName()
    • B. val s: String? = javaApi.getName()
    • C. val s = javaApi.getName() // let inference decide
    • D. val s: Any = javaApi.getName()
  8. Q20. Consider val list = mutableListOf(). Which statement is true?

    • A. list cannot be mutated because it is declared with val
    • B. list can be reassigned to a new list
    • C. list cannot be reassigned, but its contents can be mutated
    • D. Neither the reference nor the contents can change

Answer Key & Explanations

  • Q1: A - val declares an immutable reference; the type (Int) is inferred from the literal.
  • Q2: C - $name and ${name} are equivalent for simple identifiers; both are valid string templates.
  • Q3: B - Floating-point literals without suffix are Double by default.
  • Q4: A - Char models a single UTF-16 code unit, not a whole string.
  • Q5: A - Kotlin uses val/var; Boolean is the correct type name and false is a valid literal.
  • Q6: B - Prefer immutability (val) and use var only when you must reassign.
  • Q7: B - 1.0 is a Double; assigning to Float requires 1.0f or toFloat().
  • Q8: A - lateinit cannot be used with primitive types like Int; it’s for non-null var references.
  • Q9: A - const val must be a compile-time constant (primitive or String) and a val; no function calls.
  • Q10: B - Use braces for expressions or qualified property access: ${user.name}.
  • Q11: C - You cannot place underscores adjacent to a decimal point; the others are valid uses.
  • Q12: B - == checks structural equality; === checks referential identity.
  • Q13: B - null alone infers the type Nothing?, the nullable bottom type.
  • Q14: B - Primitive arrays (IntArray) avoid boxing and reduce allocations on the JVM.
  • Q15: B - Mixing Int and Long promotes the result to Long.
  • Q16: C - Kotlin arithmetic on JVM Ints overflows with two’s-complement wraparound (no exception).
  • Q17: B - Char is a UTF-16 code unit; supplementary characters require a surrogate pair in a String.
  • Q18: C - Explicit types on public APIs prevent unintended signature changes when inference evolves.
  • Q19: B - Declaring String? makes potential nullability explicit and forces safe handling.
  • Q20: C - val freezes the reference, not the object; mutating methods like add are allowed.

Sources & Further Reading

Share

More to explore

Keep exploring

Previous

Kotlin Language: Variables & Types Deep Dive (Part 1/2)

Next

Kotlin Language: Variables & Types Deep Dive (Part 2/2)