Quiz
Language quizzes
Quick checks for languages that don't run in the browser — predict the output, pick the right answer, or fill the blank. Auto-graded, nothing uploaded.
0 of 45 solved
Go
0 / 5Complete the idiomatic Go error check by filling in the blank so the branch runs only when an error occurred.
What does this program print?
After `n, err := strconv.Atoi("42x")`, the conversion fails. What are the values of `n` and `err`?
What happens when you READ from a nil map, as in `var m map[string]int; x := m["key"]`?
What is printed?
Rust
0 / 5What does this program print?
Rust has no null. To read an Option<i32> and substitute a default of 0 when it is None WITHOUT risking a panic, which expression is idiomatic?
What is the output of this program?
Fill in the blank so the loop reads each element WITHOUT consuming (moving) the Vec, leaving `v` usable afterward. Replace ____ with the single method call.
Inside a function returning Result<T, E>, what does the `?` operator do when applied to a Result value that is Err(e)?
Java
0 / 5What does this program print?
To correctly compare the *contents* of two objects (such as two String or Integer values) rather than their identity, you should call the ____ method instead of using ==.
What is the output?
Two String variables hold equal text but were built differently (e.g. one via new String(...)). Which comparison reliably reports them as equal?
What value does m() return?
C++
0 / 5What does this program print?
Why is nullptr preferred over NULL (or literal 0) for null pointers in modern C++?
What is the problem with this function?
Fill in the blank so the loop doubles every element of v in place. The element type must be captured by mutable reference.
The key "x" was never inserted. What is printed?
C#
0 / 5What does this program print?
Fill in the operator so that input is used when it is not null, otherwise the string "guest" is used.
Given string? name = null; what is the value of int len = name?.Length ?? -1;?
A struct is assigned to a new variable and one field is changed. What is the result?
What does this program print?
PHP
0 / 5Given `$config = ['debug' => 0];`, which expression returns the value of $config['debug'] (i.e. 0) WITHOUT emitting a warning when the key is missing?
What does this script print?
Fill in the blank with the operator that makes usort sort ascending by length. It returns -1, 0, or 1 by comparing both sides. What goes in the ____?
After both loops run, what does print_r output?
In PHP 8, what is the result of `var_dump(0 == 'abc');`?
Ruby
0 / 5Ruby keeps the type when both operands are integers. What does this print?
Ruby does not implicitly coerce numbers into strings. What happens when this runs?
Strings are mutable objects passed by reference. What does this print?
In Ruby, which values are falsy?
Fill in the operator so this returns `nil` instead of raising `NoMethodError` when `user` is `nil`. Replace `____`:
Kotlin
0 / 5What does this print?
Which expression creates a list you can add elements to with `.add(...)`?
Given `val name: String? = null`, what is the value of `val n = name?.length ?: -1`?
Fill in the blank with the operator that calls `.length` only if `s` is non-null (returning null otherwise) instead of throwing. Replace ____ in: `val len = s____length`
What does this print?
Swift
0 / 5What does this print?
Fill in the operator so that `count` is `0` when `value` is nil (instead of crashing). Replace ____ in: `let count = value ____ 0`
Which statement about `guard let` is correct?
After this runs, what are the values of `a.x` and `b.x`?
What does this print?