How do you start writing an if statement in Kotlin?
A. if x > y then
B. if (x > y)
C. if x > y()
D. if x > y
Select an option to see the answer and solution.
To create an array in Kotlin, use
A. The arrayOf() function
B. {}
C. []
D. None of these
Select an option to see the answer and solution.
Which feature in Kotlin helps to prevent NullPointerExceptions?
A. Safe Call Operator (?.)
B. Non-null Assertion Operator (!!)
C. Elvis Operator (?:)
D. Safe Cast Operator (as?)
Select an option to see the answer and solution.
How do you start writing a while loop in Kotlin?
A. if x > y while
B. while (x < y)
C. while x < y
D. while x < y then
Select an option to see the answer and solution.
How do you declare an array of integers in Kotlin?
A. val numbers = arrayOf(1, 2, 3)
B. val numbers = listOf(1, 2, 3)
C. val numbers = [1, 2, 3]
D. val numbers = Array(3) {0, 1, 2}
Select an option to see the answer and solution.
Which keyword is used to declare a function?
A. function
B. define
C. decl
D. fun
Select an option to see the answer and solution.
How do you declare a variable in Kotlin?
A. let myVariable = 10;
B. val myVariable: Int = 10
C. const myVariable = 10;
D. var myVariable: Int = 10
Select an option to see the answer and solution.
Which keyword is used to return a value inside a function?
A. void
B. get
C. return
D. break
Select an option to see the answer and solution.
Which statement is used to stop a loop?
A. void
B. exit
C. stop
D. break
Select an option to see the answer and solution.
Which keyword is used to create a class in Kotlin?
A. class
B. class()
C. className
D. MyClass
Select an option to see the answer and solution.
Kotlin has two equality operators, == and ===. What is the difference?
A. == determines if two primitive types are identical. === determines if two objects are identical
B. == determines if two references point to the same object. === determines if two objects have the same value
C. == determines if two objects have the same value. === determines if two strings have the same value
D. == determines if two objects have the same value. === determines if two references point to the same object
Select an option to see the answer and solution.
Your code need to try casting an object. If the cast is not possible, you do not want an exception generated, instead you want null to be assigned. Which operator can safely cast a value?
Select an option to see the answer and solution.
Which is the correct declaration of an integer array with a size of 5?
A. val arrs[5]: Int
B. val arrs = IntArray(5)
C. val arrs: Int[5]
D. val arrs = Array<Int>(5)
Select an option to see the answer and solution.
Which command will return the length of a String in Kotlin?
A. str.length
B. length(str)
C. str.lengthOf
D. str.getLength()
Select an option to see the answer and solution.
Which view attribute do you use to set the width of a View so that it adjusts to fit the content?
A. android:view_width="wrap"
B. android:layout_width="wrap_content"
C. android:layout_height="wrap_content"
D. android:layout_width="match_parent"
Select an option to see the answer and solution.
You would like to group a list of students by last name and get the total number of groups. Which line of code accomplishes this, assuming you have a list of the Student data class? Data class Student(val firstName: String, val lastName: String)
A. Println(students.groupBy{ it.lastName }.count())
B. Println(students.groupBy{ it.lastName.first() }.fold().count())
C. Delegates.rx()
D. Println(students.groupingBy{ it.lastName.first() }.size())
Select an option to see the answer and solution.
Which method changes the image resource for an ImageView in Kotlin code?
A. setImageResource()
B. setImageURI()
C. setImage()
D. setImageRes()
Select an option to see the answer and solution.
Which of the following extension methods are used in Kotlin?
A. Read texts () & Headlines ()
B. Buffer reader ()
C. Read each line ()
D. All of the above
Select an option to see the answer and solution.
Which method on an Activity inflates the app's layout and makes its views available as objects?
A. onCreate()
B. setClickListener()
C. setContentView()
D. show
Select an option to see the answer and solution.
Which is the correct way to reference bound data in the XML layout?
A. android:text="@={myDataClass.property}"
B. android:text="@={myDataClass}"
C. android:text="@={myDataClass.property.string}"
D. android:text="@={myDataClass.bound_data.property}"
Select an option to see the answer and solution.