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

Posted Date:-2022-08-11 12:25:03


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

1. .java

2. .kot

3..kt or .kts

4.andriod

Posted Date:-2022-08-11 12:24:01


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

Posted Date:-2022-08-11 12:29:38


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

Posted Date:-2022-08-11 12:33:24


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

1.Two.

2.None.

3.Four.

4.One.

Posted Date:-2022-08-11 12:57:54


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

1.//

2. /* */

3. / multi line comment /

4.None of These

Posted Date:-2022-08-11 12:31:59


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.

Posted Date:-2022-08-11 12:51:26


Question:
Kotlin is developed by?
 
 
 
 

1.Google

2.JetBrains

3.Microsoft

4.Adobe

Posted Date:-2022-08-11 12:21:33


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

1.Apache 1.0

2.Apache 2.0

3.Apache 1.1

4.None of the above

Posted Date:-2022-08-11 12:43:56


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

Posted Date:-2022-08-11 12:36:51


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)

Posted Date:-2022-08-11 12:27:56


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.

Posted Date:-2022-08-11 12:53:36


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

1. Range

2.Sealed Class

3.Elvis Operator

4.Lambda function

Posted Date:-2022-08-11 12:22:44


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

1. Range

2.Elvis Operator

3.Sealed Class

4.Lambda function

Posted Date:-2022-08-11 12:40:34


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

1. LLVM

2. .NET CLR

3.Javascript

4.None of These

Posted Date:-2022-08-11 12:30:40


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

Posted Date:-2022-08-11 12:35:40


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

1. Numbers

2.Strings

3.Arrays

4.Lists

Posted Date:-2022-08-11 12:37:44


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

1.Primary constructor

2.Secondary constructor

3.Both 1 & 2

4.None of These

Posted Date:-2022-08-11 12:34:24


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.

Posted Date:-2022-08-11 12:50:10


More MCQS

  1. Kotlin MCQ
  2. Kotlin MCQ Set 1
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website 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!