Kotlin Part-II
Sign in to Google to save your progress. Learn more
Your function is passed by a parameter obj of type Any. Which code snippet shows a way to retrieve the original type of obj, including package information? *
1 point
Both const and @JvmField create constants. What can const do that @JvmField cannot? *
1 point
Captionless Image
Which is the correct declaration of an integer array with a size of 5? *
1 point
You have an enum class Signal that represents the state of a network connection. You want to print the position number of the SENDING enum. Which line of code does that? *
1 point
Captionless Image
Which line of code is a shorter, more idiomatic version of the displayed snippet? *
1 point
Captionless Image
The code below is expected to display the numbers from 1 to 10, but it does not. Why? *
1 point
Captionless Image
Which snippet correctly shows setting the variable max to whichever variable holds the greatest value, a or b, using idiomatic Kotlin? *
1 point
What is the correct way to initialize a nullable variable? *
1 point
This function generates Fibonacci sequence. Which function is missing? *
1 point
Captionless Image
In this code snippet, why does the compiler not allow the value of y to change? *
1 point
Captionless Image
The code snippet below translates a database user to a model user. Because their names are both User, you must use their fully qualified names, which is cumbersome. You do not have access to either of the imported classes' source code. How can you shorten the type names? *
1 point
Captionless Image
How can you retrieve the value of the property codeName without referring to it by name or destructuring? *
1 point
Captionless Image
Kotlin has two equality operators, == and ===. What is the difference? *
1 point
What is the difference between the declarations of COLOR and SIZE? *
1 point
Captionless Image
In order to subclass the Person class, what is one thing you must do? *
1 point
Captionless Image
Why doesn't this code compile? *
1 point
Captionless Image
Which is the proper way to declare a singleton named DatabaseManager? *
1 point
Why does not this code snippet compile? *
1 point
Captionless Image
What three methods does this class have? *
1 point
Captionless Image
You would like to know each time a class property is updated. Which code snippet shows a built-in delegated property that can accomplish this? *
1 point
You have a when expression for all of the subclasses of the class Attribute. To satisfy the when, you must include an else clause. Unfortunately, whenever a new subclass is added, it returns unknown. You would prefer to remove the else clause so the compiler generates an error for unknown subtypes. What is one simple thing you can do to achieve this? *
1 point
Captionless Image
You are creating a Kotlin unit test library. What else should you add to make the following code compile without error? *
1 point
Captionless Image
The code below shows a typical way to show both index and value in many languages, including Kotlin. Which line of code shows a way to get both index and value more idiomatically? *
1 point
Captionless Image
You have created a class that should be visible only to the other code in its module. Which modifier do you use? *
1 point
The Kotlin .. operator can be written as which function? *
1 point
Submit
Clear form
This content is neither created nor endorsed by Google.