Kotlin (programming language)/Kotlin MCQ Set 1 Sample Test,Sample questions

Question:
 All classes in Kotlin classes are by default?

1. public

2.final

3.sealed

4.abstract


Question:
 Which file extension is used to save Kotlin files.

1. .java

2. .kot

3..kt or .kts

4.andriod


Question:
6. What is an immutable variable?
 

1.A variable that cannot change, read-only

2.A variable used for string interpolation

3. A variable that can be changed

4.None of these


Question:
9. How do you get the length of a string in Kotlin?
 
 

1.str.length

2.length(str)

3. str.lengthOf

4.None of the mentioned


Question:
How many different kinds of constructors are available for kotlin classes?

1.Two.

2.None.

3.Four.

4.One.


Question:
How to make a multi lined comment in Kotlin?

1.//

2. /* */

3. / multi line comment /

4.None of These


Question:
If a class has one or more secondary constructors, what must each of them do?

1.Each secondary constructor must call super().

2.Each secondary constructor must call base().

3.Each secondary constructor must directly or indirectly delegate to the primary.

4.Each secondary constructor must have the same name as the class.


Question:
Kotlin is developed by?
 
 
 
 

1.Google

2.JetBrains

3.Microsoft

4.Adobe


Question:
Kotlin was developed under the .......... license.

1.Apache 1.0

2.Apache 2.0

3.Apache 1.1

4.None of the above


Question:
There are two types of constructors in Kotlin which are-

1. Primary & Secondary constructor

2.Default & No-arg constructor

3.Parameterized & constant Constructor

4.None of the above


Question:
What is correct way to create an arraylist in Kotlin?

1. val map = hashMapOf(1 to "one", 2 to "two", 3 to "three")

2. enum class Color {RED, GREEN, BLUE}

3. val list = arrayListOf(1, 2, 3)

4.val set = hashSetOf(1, 2, 3)


Question:
When you can omit constructor keyword from the primary constructor?

1.It can be omitted only if an init block is defined

2.It can be omitted anytime; it is not mandatory.

3.It can be omitted if secondary constructors are defined.

4.It can be omitted when the primary constructor does not have any modifiers or annotations.


Question:
Which of following is used to handle null exceptions in Kotlin?

1. Range

2.Sealed Class

3.Elvis Operator

4.Lambda function


Question:
Which of following option is used to handle null exceptions in Kotlin?

1. Range

2.Elvis Operator

3.Sealed Class

4.Lambda function


Question:
Which of follwing targets currently not supported by Kotlin?

1. LLVM

2. .NET CLR

3.Javascript

4.None of These


Question:
Which of the following extension methods are used in Kotlin?

1. Read texts () & Headlines ()

2.Buffer reader ()

3.Read each line ()

4.All of the above


Question:
Which of the following is not the basic data types in Kotlin?

1. Numbers

2.Strings

3.Arrays

4.Lists


Question:
Which of the followings constructors are available in Kotlin?
 
 
 

1.Primary constructor

2.Secondary constructor

3.Both 1 & 2

4.None of These


Question:
You have created an array to hold three strings. When you run the code bellow, the compiler displays an error. Why does the code fail? val names = arrayOf(3) names[3]= "Delta"

1.Arrays use zero-based indexes. The value 3 is outside of the array's bounds

2.You accessed the element with an index but should have used.set(

3.You declared the array with val but should have used var

4.You cannot changes the value of an element of an array. You should have used a mutable list.


More MCQS

  1. Kotlin MCQ
  2. Kotlin MCQ Set 1
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!