- What is the primary purpose of Kotlin?
- A) Web Development
- B) Mobile Development
- C) Data Science
- D) System Programming
- Which company developed Kotlin?
- A) Microsoft
- B) JetBrains
- C) Google
- D) Oracle
- Kotlin is fully interoperable with which language?
- A) Swift
- B) Java
- C) C#
- D) Python
- What keyword is used to declare a variable in Kotlin?
- A) var
- B) let
- C) def
- D) set
- What is the extension of Kotlin source files?
- A) .k
- B) .kt
- C) .kotlin
- D) .kts
- Which of the following is a valid way to declare a constant in Kotlin?
- A) const val
- B) val const
- C) final val
- D) val constant
- How do you define a function in Kotlin?
- A) function myFunction() {}
- B) fun myFunction() {}
- C) def myFunction() {}
- D) myFunction() {}
- Which of the following keywords is used to define a class in Kotlin?
- A) class
- B) define
- C) object
- D) module
- What symbol is used for comments in Kotlin?
- A) //
- B) /*
- C) #
- D) —
- What type is used to represent a nullable variable in Kotlin?
- A) ?
- B) null
- C) undefined
- D) None
- How do you create an immutable list in Kotlin?
- A) listOf()
- B) mutableListOf()
- C) arrayOf()
- D) ArrayList()
- Which collection class allows duplicates in Kotlin?
- A) Set
- B) List
- C) Map
- D) Hashtable
- What is the correct syntax for a for loop in Kotlin?
- A) for (i in 1..10) {}
- B) for i in 1 to 10 {}
- C) loop (i: 1 to 10) {}
- D) for i = 1 to 10 {}
- How do you handle exceptions in Kotlin?
- A) try-catch
- B) catch-throw
- C) exception-handle
- D) throw-try
- Which keyword is used for inheritance in Kotlin?
- A) extends
- B) inherits
- C) :
- D) from
- What is the default visibility modifier for classes in Kotlin?
- A) public
- B) private
- C) internal
- D) protected
- Which of the following is used for testing in Kotlin?
- A) JUnit
- B) NUnit
- C) TestNG
- D) Mocha
- What keyword is used to define a data class in Kotlin?
- A) data
- B) class
- C) object
- D) model
- How do you define an interface in Kotlin?
- A) interface MyInterface {}
- B) MyInterface interface {}
- C) class MyInterface {}
- D) object MyInterface {}
- What type of loop executes at least once in Kotlin?
- A) for loop
- B) while loop
- C) do-while loop
- D) infinite loop
- How do you declare a property in a Kotlin class?
- A) var name: String
- B) property name: String
- C) let name: String
- D) field name: String
- Which function is used to read user input in Kotlin?
- A) input()
- B) readLine()
- C) readInput()
- D) scan()
- How would you declare a generic type in Kotlin?
- A) <T>
- B) <E>
- C) <R>
- D) <K>
- What is the purpose of the
companion objectin Kotlin?- A) Static members
- B) Instance variables
- C) Functions only
- D) Inheritance
- Which file extension is used for Kotlin scripts?
- A) .ks
- B) .kts
- C) .kat
- D) .kotlin
- How do you define a lambda expression in Kotlin?
- A) { x -> x + 2 }
- B) (x) => x + 2
- C) lambda x: x + 2
- D) (x) { return x + 2 }
- Which function can be used to concatenate strings in Kotlin?
- A) concat()
- B) append()
- C) + operator
- D) join()
- What does the
!operator do in Kotlin?- A) Not operator
- B) Mandatory operator
- C) Nullable operator
- D) Private modifier
- How do you access a property in a class in Kotlin?
- A) className.propertyName
- B) propertyName.className
- C) instanceName.propertyName
- D) propertyName(instanceName)
- In Kotlin, what is the use of
lateinit?- A) Initialize later
- B) Late object creation
- C) Delay function execution
- D) Asynchronous execution
- How do you create a single instance class in Kotlin?
- A) class Singleton {}
- B) object Singleton {}
- C) single class Singleton {}
- D) instance Singleton {}
- What is the result of the expression
5 == 5in Kotlin?- A) 0
- B) true
- C) null
- D) false
- Which keyword is used to define an abstract class in Kotlin?
- A) abstract
- B) class
- C) virtual
- D) interface
- What does the
applyfunction do in Kotlin?- A) Applies a transformation
- B) Executes a block of code on an object
- C) Returns a new object
- D) Sets a new value
- How do you define a list in Kotlin that is mutable?
- A) mutableListOf()
- B) ArrayList()
- C) arrayOf()
- D) List()
- What does the
withfunction do in Kotlin?- A) Executes a block of code within a context
- B) Merges two objects
- C) Transfers data
- D) Clones an object
- Which of the following built-in functions allows filtering a list?
- A) filter()
- B) select()
- C) choose()
- D) find()
- How do you define an enum class in Kotlin?
- A) enum EnumClass {}
- B) class EnumClass {}
- C) enum class EnumClass {}
- D) class enum EnumClass {}
- What is the purpose of the
inkeyword in Kotlin?- A) Define range
- B) Define extend
- C) Specify nullability
- D) A member keyword
- Which method can be used to sort a list in Kotlin?
- A) orderBy()
- B) sort()
- C) sorted()
- D) arrange()
- How do you define a secondary constructor in a Kotlin class?
- A) constructor(param: Type) {}
- B) className(param: Type) {}
- C) init(param: Type) {}
- D) secondary constructor(param: Type) {}
- What is the purpose of the
sealedclass in Kotlin?- A) Define single inheritance
- B) Restrict class hierarchies
- C) Create singleton classes
- D) Allow inheritance
- How do you declare a functional type in Kotlin?
- A) (Type) -> Type
- B) Type -> Type
- C) fun Type: Type
- D) function Type -> Type
- What operator is used to call a super class method in Kotlin?
- A) %
- B) super
- C) &
- D) call
- How do you format a string in Kotlin?
- A) String.format()
- B) formatString()
- C) “$value”
- D) String.interpolate()
- Which feature was introduced in Kotlin 1.3?
- A) Coroutines
- B) Type inference
- C) Lambda expressions
- D) Data classes
- What is the purpose of the
modifierin Kotlin functions?- A) Change access
- B) Change scope
- C) Use inline
- D) Mark description
- Which operator is used for safe calls in Kotlin?
- A) ?
- B) !!
- C) ?
- D) @
- What is the purpose of the
whenexpression in Kotlin?- A) Loop iteration
- B) Conditional statements
- C) Data transformation
- D) Event handling
- How do you start Kotlin’s REPL (Read-Eval-Print Loop)?
- A) Kotlin REPL
- B) Run Kotlin
- C) kotlinc
- D) kotlin