Vidyalelo
Computer Science · all questions

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

292

Questions

12/15

Page

Pick an option on a question to see the right answer and solution.

How do you start writing an if statement in Kotlin?

Select an option to see the answer and solution.

To create an array in Kotlin, use

Select an option to see the answer and solution.

Which feature in Kotlin helps to prevent NullPointerExceptions?

Select an option to see the answer and solution.

How do you start writing a while loop in Kotlin?

Select an option to see the answer and solution.

How do you declare an array of integers in Kotlin?

Select an option to see the answer and solution.

Which keyword is used to declare a function?

Select an option to see the answer and solution.

How do you declare a variable in Kotlin?

Select an option to see the answer and solution.

Which keyword is used to return a value inside a function?

Select an option to see the answer and solution.

Which statement is used to stop a loop?

Select an option to see the answer and solution.

Which keyword is used to create a class in Kotlin?

Select an option to see the answer and solution.

Kotlin has two equality operators, == and ===. What is the difference?

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?

Select an option to see the answer and solution.

Which command will return the length of a String in Kotlin?

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?

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)

Select an option to see the answer and solution.

Which method changes the image resource for an ImageView in Kotlin code?

Select an option to see the answer and solution.

Which of the following extension methods are used in Kotlin?

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?

Select an option to see the answer and solution.

Which is the correct way to reference bound data in the XML layout?

Select an option to see the answer and solution.