अभी पंजीकरण करें

लॉग इन करें

पासवर्ड खो गया

आपका पासवर्ड खो गया है? कृपया अपना पूरा ईमेल दर्ज करें. आपको एक लिंक प्राप्त होगा और आप ईमेल के माध्यम से एक नया पासवर्ड बनाएंगे.

पोस्ट जोड़ें

पोस्ट जोड़ने के लिए आपको लॉगिन करना होगा .

प्रश्न जोड़ें

प्रश्न पूछने के लिए आपको लॉगिन करना होगा.

लॉग इन करें

अभी पंजीकरण करें

स्कॉलरसार्क.कॉम में आपका स्वागत है! आपका पंजीकरण आपको इस प्लेटफॉर्म की अधिक सुविधाओं का उपयोग करने की अनुमति देगा. आप सवाल पूछ सकते हैं, योगदान दें या उत्तर दें, अन्य उपयोगकर्ताओं के प्रोफ़ाइल देखें और बहुत कुछ. अभी पंजीकरण करें!

LinkedIn skill assessment answers and questions — Kotlin

Step into the world of Kotlin with our comprehensive लिंक्डइन कौशल मूल्यांकन मार्गदर्शक. This indispensable resource is designed to empower you with the knowledge and confidence to excel in the LinkedIn Kotlin skill assessment. Our guide features a collection of meticulously curated प्रशन तथा जवाब that encapsulate the versatility and power of Kotlin.

Whether you’re a beginner venturing into the realm of Kotlin or an experienced developer seeking to refine your skills, this guide is your ultimate companion. Immerse yourself in this enriching journey and let’s ace the LinkedIn Kotlin skill assessment साथ में!.

Q1. You would like to print each score on its own line with its cardinal position. Without using var या val, which method allows iteration with both the value and its position?

fun main() {
  val highScores = listOf(4000, 2000, 10200, 12000, 9030)
}
  • .withIndex()
  • .forEachIndexed()
  • .forEach()
  • .forIndexes()

संदर्भ

Q2. जब Airplane class is instantiated, it displays Aircraft = null, नहीं Aircraft = C130 क्यों?

abstract class Aircraft {
  init { println("Aircraft = ${getName()}") }
  abstract fun getName(): String
}
class Airplane(private val name: String) : Aircraft() {
  override fun getName(): String = name
}
  • Classes are initialized in the same order they are in the file, इसलिए, Aircraft should appear after Airplane
  • The code needs to pass the parameter to the base class’s primary constructor. Since it does not, it receives a null
  • Abstract function always returns null
  • A superclass is initialized before its subclass. इसलिए, name has not been set before it is rendered

संदर्भ discussion

Q3. Kotlin interfaces and abstract classes are very similar. What is one thing abstract class can do that interfaces cannot?

  • Only abstract classes are inheritable by subclasses
  • Only abstract classes can inherit from multiple superclasses
  • Only abstract classes can have abstract methods
  • Only abstract classes can store state

संदर्भ

Q4. Inside an extension function, what is the name of the variable that corresponds to the receiver object

  • The variable is named यह
  • The variable is named यह
  • The variable is named receiver
  • The variable is named default

संदर्भ

Q5. Your application has an जोड़ना समारोह. How could you use its invoke methods and display the results?

fun add(a: Int, b: Int): Int {
  return a + b
}
  • println(add(5,10).invoke())
  • println(::add.invoke(5, 10))
  • println(::add.invoke{5, 10})
  • println(add.invoke(5,10))

संदर्भ

Q6. What is the entry point for a Kotlin application?

  • fun static main(){}
  • fun main(){}
  • fun Main(){}
  • public static void main(){}

क्यू 7. You are writing a console app in Kotlin that processes tests entered by the user. If the user enters an empty string, the program exits. Which kind of loop would work best for this app? Keep in mind that the loop is entered at least once

  • a do..while loop
  • a for loop
  • a while loop
  • a forEach loop

संदर्भ

क्यू 8. You pass an integer to a function expecting type Any. It works without issue. Why is a primitive integer able to work with a function that expects an object?

fun showHashCode(obj: Any){
  println("${obj.hashCode()}")
}
fun main() {
  showHashCode(1)
}
  • While the code runs, it does not produce correct results
  • The integer is always a class
  • The compiler runs an implicit .toClass() method on the integer
  • The integer is autoboxed to a Kotlin Int class

संदर्भ

प्रश्न 9. You have started a long-running coroutine whose job you have assigned to a variable named task. If the need arose, how could you abort the coroutine?

val task = launch {
  // long running job
}
  • task.join()
  • task.abort()
  • job.stop()
  • task.cancel()

संदर्भ

प्र10. You are attempting to assign an integer variable to a long variable, but the Kotlin compiler flags it as an error. आप अभी भी आधे घर में नहीं हैं?

  • You must wrap all implicit conversions in a try/catch block
  • You can only assign Long to an Int, not the other way around
  • There is no implicit conversion from Int प्रति Long
  • All integers in Kotlin are of type Long

संदर्भ

प्रश्न 11. You have written a snippet of code to display the results of the roll of a six-sided die. When the die displays from 3 प्रति 6 सहित, you want to display a special message. Using a Kotlin range, what code should you add?

when (die) {
  1 -> println("die is 1")
  2 -> println("die is 2")
  ___ -> println("die is between 3 and 6")
  else -> println("die is unknown")
}
  • 3,4,5,6
  • in 3..6
  • 3 : 6
  • {3,4,5,6}

संदर्भ

प्र12. The function typeChecker receives a parameter obj of type Any. Based upon the type of obj, it prints different messages for Int, String, Double, and Float types; if not any of the mentioned types, it printsunknown type”. What operator allows you to determine the type of an object?

  • instanceof
  • is
  • typeof
  • as

संदर्भ

प्रश्न 13. This code does not print any output to the console. What is wrong?

firstName?.let {
  println("Greeting $firstname!")
}
  • A null pointer exception is thrown
  • firstName is equal to null
  • firstName is equal to an empty string
  • firstName is equal to Boolean false

संदर्भ

प्र14. You have a function simple() that is called frequently in your code. You place the inline prefix on the function. What effect does it have on the code?

inline fun simple(x: Int): Int{
  return x * x
}

fun main() {
  for(count in 1..1000) {
    simple(count)
  }
}
  • The code will give a stack overflow error
  • The compiler warns of insignificant performance impact
  • The compiler warns of significant memory usage
  • The code is significantly faster

संदर्भ

प्रश्न 15. How do you fill in the blank below to display all of the even numbers from 1 प्रति 10 with least amount of code?

for (_____) {
  println("There are $count butterflies.")
}
  • count in 1..10
  • count in 2..10 step 2
  • count in 1..10 % 2
  • var count=2; count <= 10; count+=2

संदर्भ

प्र16. What value is printed by println()?

val set = setOf("apple", "pear", "orange", "apple")
println(set.count())
  • 3
  • 4
  • 1
  • 5

संदर्भ

प्रश्न 17. Which line of code shows how to display a nullable string’s length and shows 0 instead of null?

  • println(b!!.length ?: 0)
  • println(b?.length ?: 0)
  • println(b?.length ?? 0)
  • println(b == null? 0: b.length)

प्रश्न 18. In the file main.kt, you are filtering a list of integers and want to use an already existing function, removeBadValues. What is the proper way to invoke the function from filter in the line below?

val list2 = (80..100).toList().filter(_____)
  • ::removeBadValues
  • GlobalScope.removeBadValues()
  • Mainkt.removeBadValues
  • removeBadValues

संदर्भ

क्यू19. Which code snippet correctly shows a for loop using a range to display “1 2 3 4 5 6”?

  • for(z in 1..7) println("$z ")
  • for(z in 1..6) print("$z ")
  • for(z in 1 to 6) print("$z ")
  • for(z in 1..7) print("$z ")

संदर्भ

प्र20. You are upgrading a Java class to Kotlin. What should you use to replace the Java class’s static fields?

  • an anonymous object
  • a static property
  • a companion object
  • a backing field

संदर्भ

प्र21. 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?

  • as?
  • ??
  • is
  • as

संदर्भ

प्र22. Kotlin will not compile this code snippet. What is wrong?

class Employee
class Manager : Employee()
  • In order to inherit from a class, it must be marked खोलना
  • In order to inherit from a class, it must be marked जनता
  • In order to inherit from a class, it must be marked sealed
  • In order to inherit from a class, it must be marked override

संदर्भ

प्र23. Which function changes the value of the element at the current iterator location?

  • change()
  • modify()
  • set()
  • assign()

संदर्भ

प्र24. From the Supervisor subclass, how do you call the Employee class’s display() तरीका?

open class Employee(){
  open fun display() = println("Employee display()")
}
class Supervisor : Employee() {
  override fun display() {
    println("Supervisor display()")
  }
}
  • Employee.display()
  • ::display()
  • super.display()
  • override.display()

संदर्भ

प्रश्न25. The code below was compiled and executed without issue before the addition of the line declaring errorStatus. Why does this line break the code?

sealed class Status(){
  object Error : Status()
  class Success : Status()
}
fun main(){
  var successStatus = Status.Success()
  var errorStatus = Status.Error()
}
  • StatusError is an object, not a class and cannot be instantiated
  • Only one instance of the class Status can be instantiated at a time
  • Status.Error must be declared as an immutable type
  • Status.Error is pribate to class and cannot be declared externally

संदर्भ

प्र26. The code below is expected to display the numbers from 1 प्रति 10, but it does not. आप अभी भी आधे घर में नहीं हैं?

val seq = sequence { yieldAll(1..20) }
  .filter { it < 11 }
  println(seq)
  • You cannot assign a sequence to a variable
  • To produce result, a sequence must have terminal operation. इस मामले में, it needs a .toList()
  • NS .filter{ it < 11 } should be .filter{ it > 11 }
  • NS yieldAll(1..20) should be yieldAll(1..10)

संदर्भ

प्र27. What three methods does this class have?

class Person
  • equals(), hashCode(), and toString()
  • equals(), toHash(), and super()
  • print(), println(), and toString()
  • clone(), equals(), and super()

संदर्भ

प्रश्न 28. Which is the proper way to declare a singleton named DatabaseManager?

  • object DatabaseManager {}
  • singleton DatabaseManager {}
  • static class DatabaseManager {}
  • data class DatabaseManager {}

संदर्भ

प्र29. In order to subclass the Person class, what is one thing you must do?

abstract class Person(val name: String) {
  abstract fun displayJob(description: String)
}
  • The subclass must be marked sealed
  • You must override the displayJob() तरीका
  • You must mark the subclass as final
  • An abstract class cannot be extended, so you must change it to open

संदर्भ

क्यू30. The code snippet below translates a database user to a model user. Because their names are both User, you must use their fully qualified names, which is cumbersome. You do not have access to either of the imported classessource code. How can you shorten the type names?

import com.tekadept.app.model.User
import com.tekadept.app.database.User

class UserService{
  fun translateUser(user: com.tekadept.app.database.User): User =
    com.tekadept.app.model.User("${user.first} ${user.last}")
}
  • Use import as to change the type name
  • Create subtypes with shorter names
  • Create interfaces with shorter names
  • Create extension classes with shorter names

संदर्भ

प्रश्न31. Your function is passed by a parameter obj of type Any. Which code snippet shows a way to retrieve the original type of obj, including package information?

  • obj.classInfo()
  • obj.typeInfo()
  • obj::class.simpleName
  • obj::class

संदर्भ

प्र32. Which is the correct declaration of an integer array with a size of 5?

  • val arrs[5]: Int
  • val arrs = IntArray(5)
  • val arrs: Int[5]
  • val arrs = Array<Int>(5)

संदर्भ

प्रश्न 33. You have created a class that should be visible only to the other code in its module. Which modifier do you use?

  • internal
  • private
  • public
  • protected

संदर्भ

प्रश्न34. Kotlin has two equality operators, == and ===. क्या अंतर है?

  • == determines if two primitive types are identical. === determines if two objects are identical
  • == determines if two references point to the same object. === determines if two objects have the same value
  • == determines if two objects have the same value. === determines if two strings have the same value
  • == determines if two objects have the same value. === determines if two references point to the same object

संदर्भ

क्यू35. Which snippet correctly shows setting the variable max to whichever variable holds the greatest value, a or b, using idiomatic Kotlin?

  • val max3 = a.max(b)
  • val max = a > b ? a : b
  • val max = if (a > b) a else b
  • if (a > b) max = a else max = b

संदर्भ

प्र36. You have an enum class Signal that represents the state of a network connection. You want to print the position number of the SENDING enum. Which line of code does that?

enum class Signal { OPEN, CLOSED, SENDING }
  • println(Signal.SENDING.position())
  • println(Signal.SENDING.hashCode())
  • println(Signal.SENDING)
  • println(Signal.SENDING.ordinal)

संदर्भ

प्रश्न37. Both const and @JvmField create constants. What can const do that @JvmField cannot?

class Detail {
  companion object {
    const val COLOR = "Blue"
    @JvmField val SIZE = "Really Big"
  }
}
  • const is compatible with Java, लेकिन @JvmField is not
  • The compiler will inline const so it is faster and more memory efficient
  • Virtually any type can be used with const but not @JvmField
  • const can also be used with mutable types

संदर्भ

प्रश्न 38. You have a when expression for all of the subclasses of the class Attribute. To satisfy the when, you must include an else clause. दुर्भाग्य से, whenever a new subclass is added, it returns unknown. You would prefer to remove the else clause so the compiler generates an error for unknown subtypes. What is one simple thing you can do to achieve this?

open class Attribute
class Href: Attribute()
class Src: Attribute()
class Alt: Attribute()

fun getAttribute(attribute: Attribute) : String {
  return when (attribute) {
    is Href -> "href"
    is Alt -> "alt"
    is Src -> "src"
    else -> "unknown"
  }
}
  • Replace open साथ closed
  • Replace open साथ sealed
  • Replace open साथ private
  • Replace open साथ public

संदर्भ

प्र39. You would like to know each time a class property is updated. Which code snippet shows a built-in delegated property that can accomplish this?

  • Delegates.watcher()
  • Delegates.observable()
  • Delegates.rx()
  • Delegates.observer()

संदर्भ

क्यू40. Why doesn’t this code compile?

val addend = 1
infix fun Int.add(added: Int=1) = this + addend
fun main(){
  val msg = "Hello"
  println( msg shouldMatch "Hello")
  println( 10 multiply 5 + 2)
  println( 10 add 5)
}
  • infix function must be marked public
  • In Kotlin, add is a keyword
  • Extension functions use it, नहीं this, as the default parameter name
  • infix functions cannot have default values

संदर्भ

प्र41. What is the correct way to initialize a nullable variable?

  • val name = null
  • var name: String
  • val name: String
  • val name: String? = null

प्र42. Which line of code is a shorter, more idiomatic version of the displayed snippet?

val len: Int = if (x != null) x.length else -1
  • val len = x?.let{x.len} else {-1}
  • val len = x!!.length ?: -1
  • val len:Int = (x != null)? x.length : -1
  • val len = x?.length ?: -1

प्रश्न 43. You are creating a Kotlin unit test library. What else you should add to make the following code compile without error?

fun String.shouldEqual(value: String) = this == value
fun main(){
  val msg = "test message"
  println(msg shouldEqual "test message")
}
  • The extension function should be marked public
  • Add the prefix operator को shouldMatch extension function
  • The code is not legal in Kotlin (should be println(msg.shouldEqual("test message")))
  • Add the prefix infix को shouldMatch extension function

प्रश्न 44. What is the difference between the declarations of COLOR and SIZE?

class Record{
  companion object {
    const val COLOR = "Red"
    val SIZE = "Large"
  }
}
  • तब से COLOR तथा SIZE are both immutable, they are identical internally
  • Both are immutable, but the use of the keyword const makes COLOR slower and less space efficient than SIZE
  • const makes COLOR और तेज, but not compatible with Java. Without const, SIZE is still compatible with Java
  • Both are immutable, but the use of the keyword const makes COLOR faster and more space efficient than SIZE

संदर्भ

क्यू45. Why does not this code snippet compile?

class Cat (name: String) {
  fun greet() { println("Hello ${this.name}") }
}

fun main() {
  val thunderCat = Cat("ThunderCat")
  thunderCat.greet()
}
  • Because name is a class parameter, not a property-it is unresolved main().
  • In order to create an instance of a class, you need the keyword new
  • The reference to name needs to be scoped to the class, so it should be this.name
  • Classes cannot be immutable. You need to change var प्रति val

ध्यान दें: डिफ़ॉल्ट रूप से, constructor parameters can only be used in the initializer blocks or property initializers declared in the class body. इसलिए, to let the greet function have access to the name parameter, it should be declared as a property: class Cat (val name: String) { ... }

संदर्भ

प्र46. The code below shows a typical way to show both index and value in many languages, including Kotlin. Which line of code shows a way to get both index and value more idiomatically?

var ndx = 0;
for (value in 1..5){
  println("$ndx - $value")
  ndx++
}
  • for( (ndx, value) in (1..20).withIndex() ){
  • for( (ndx, value) in (1..20).pair() ){
  • for( Pair(ndx, value) in 1..20 ){
  • for( (ndx, value) in *(1..20) ){

संदर्भ

प्रश्न 47. The Kotlin .. operator can be written as which function?

  • a.from(b)
  • a.range(b)
  • a.rangeTo(b)
  • a.to(b)

संदर्भ

प्रश्न 48. How can you retrieve the value of the property codeName without referring to it by name or destructuring?

data class Project(var codeName: String, var version: String)
fun main(){
  val proj = Project("Chilli Pepper", "2.1.0")
}
  • proj.0
  • proj[0]
  • proj[1]
  • proj.component1()

संदर्भ

प्र49. This function generates the Fibonacci sequence. Which function is missing?

fun fibonacci() = sequence {
  var params = Pair(0, 1)
  while (true) {
    ___(params.first)
    params = Pair(params.second, params.first + params.second)
  }
}
  • with()
  • yield()
  • skip()
  • return()

संदर्भ

क्यू50. In this code snippet, why does the compiler not allow the value of y to change?

for(y in 1..100) y+=2
  • y must be declared with var to be mutable
  • y is an implicitly immutable value
  • y can change only in a while loop
  • In order to change y, it must be declared outside of the loop

प्रश्न51. You have created a data class, Point, that holds two properties, x and y, representing a point on a grid. You want to use the hash symbol for subtraction on the Point class, but the code as shown will not compile. How can you fix it?

data class Point(val x: Int, val y: Int)

operator fun Point.plus(other: Point) = Point(x + other.x, y + other.y)
operator fun Point.hash(other: Point) = Point(x - other.x, y - other.y)

fun main() {
    val point1 = Point(10, 20)
    val point2 = Point(20, 30)
    println(point1 + point2)
    println(point1 # point2)
}
  • You cannot; the hash symbol is not a valid operator.
  • You should replace the word hash with octothorpe, the actual name for the symbol.
  • You should use minus instead of hash, then type alias the minus symbol.
  • You need to replace the operator with the word infix.

प्रश्न52. This code snippet compiles without error, but never prints the results when executed. What could be wrong?

val result = generateSequence(1) { it + 1 }.toList()
println(result)
  • The sequence lacks a terminal operation.
  • The sequence is infinite and lacks an intermediate operation to make it परिमित.
  • The expression should begin with generateSequence(0).
  • NS it parameter should be replaced with this.

संदर्भ

प्रश्न53. An error is generated when you try to compile the following code. How should you change the call to printStudents to fix the error?

fun main() {
    val students = arrayOf("Abel", "Bill", "Cindy", "Darla")
    printStudents(students)
}

fun printStudents(vararg students: String) {
    for(student in students) println(student)
}
  • printStudents(students.toList())
  • printStudents(students!!)
  • printStudents(*students)
  • printStudents(students[])

संदर्भ

प्रश्न54. Both y and z are immutable references pointing to fixed-size collections of the same four integers. Are there any differences?

val y = arrayOf(10, 20, 30, 40)
val z = listOf(10, 20, 30, 40)
  • You can modify the contents of the elements in y but not z.
  • There are not any differences. y तथा z are a type alias of the same type.
  • You add more elements to z since it is a list.
  • You can modify the contents of the elements in z but not y.

प्रश्न55. The code snippet compiles and runs without issue, but does not wait for the coroutine to show the “वहाँ” संदेश. Which line of code will cause the code to wait for the coroutine to finish before exiting?

fun main() = runBlocking {
    val task = GlobalScope.launch {
        delay(1000L)
        println("there")
    }
    println("Hello,")
}
  • task.complete()
  • task.wait()
  • task.join()
  • task.cancel()

संदर्भ

प्रश्न56. 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)
  • println(students.groupBy{ it.lastName }.count())
  • println(students.groupBy{ it.lastName.first() }.fold().count())
  • println(students.groupingBy{ it.lastName.first() }.count())
  • println(students.groupingBy{ it.lastName.first() }.size())

संदर्भ

प्रश्न57. Class BB inherits from class AA. BB uses a different method to calculate the price. As shown, the code does not compile. What changes are needed to resolve the compilation error?

open class AA() {
     var price: Int = 0
        get() = field + 10
}
class BB() : AA() {
     var price: Int = 0
        get() = field + 20
}
  • You need to add a lateinit modifier to AA.price.
  • You simply need to add an override modifier to BB.price.
  • You need to add an open modifier to AA.price and an override modifier to BB.price.
  • You need to add a public modifier to AA.price और एक protected modifier to BB.price.

संदर्भ

प्र 58. What is the output of this code?

val quote = "The eagle has landed."
println("The length of the quote is $quote.length")
  • The length of the quote is The eagle has landed.
  • A compilation error is displayed.
  • The length of the quote is 21
  • The length of the quote is The eagle has landed..length

संदर्भ

प्रश्न59. You have an unordered list of high scores. Which is the simple method to sort the highScores in descending order?

fun main() {
    val highScores = listOf(4000, 2000, 10200, 12000, 9030)
  • .sortedByDescending()
  • .descending()
  • .sortedDescending()
  • .sort("DESC")

संदर्भ

क्यू 60. Your class has a property name that gets assigned later. You do not want it to be a nullable type. Using a delegate, how should you declare it?

  • lateinit var name: String // lateinit is modifier not delegate
  • var name: String by lazy
  • var name: String by Delegates.notNull()
  • var name: String? = null

संदर्भ

प्रश्न 61. You want to know each time a class property is updated. If the new value is not within range, you want to stop the update. Which code snippet shows a built-in delegated property that can accomplish this?

  • Delegates.vetoable()
  • Delegates.cancellable()
  • Delegates.observer()
  • Delegates.watcher()

संदर्भ

प्रश्न 62. Which line of code shows how to call a Fibonacci function, bypass the first three elements, grab the next six, and sort the elements in descending order?

  • val sorted = fibonacci().skip(3).take(6).sortedDescending().toList()
  • val sorted = fibonacci().skip(3).take(6).sortedByDescending().toList()
  • val sorted = fibonacci().skip(3).limit(6).sortedByDescending().toList()
  • val sorted = fibonacci().drop(3).take(6).sortedDescending().toList()

संदर्भ

प्रश्न 63. You have two arrays, a and b. Which line combines a and b as a list containing the contents of both?

val a = arrayOf(1, 2, 3)
val b = arrayOf(100, 200, 3000)
  • val c = list of (a, b)
  • val c = a + b
  • val c = listOf(a+b)
  • val c = listOf(*a, *b)
  • संदर्भ

प्रश्न 64. This code occasionally throws a null pointer exception (NPE). How can you change the code so it never throws as NPE?

println("length of First Name = ${firstName!!.length}")
  • Replace !!. साथ ?.
  • Replace !!. साथ ?:.
  • Surround the line with a try/catch block.
  • Replace !!. साथ ?.let.

संदर्भ

प्रश्न 65. What is the execution order of init blocks and properties during initialization?

  • All of the properties are executed in order of appearance, and then the init blocks are executed.
  • The init blocks and properties are executed in the same order they appear in the code.
  • All of the init blocks are executed in order of appearance, and then the properties are executed.
  • The order of execution is not guaranteed, so code should be written accordingly.

संदर्भ

प्रश्न 66. Both const and @JvmField create constants. What can @JvmField do that const cannot?

class Styles {
  companion object {
    const val COLOR = "Blue"
      @JvmField val SIZE = "Really big"
   }
}
  • const works only with strings and primitives. @JvmField does not have that restriction.
  • @JvmField works as a top-level variable, लेकिन const works only in a class.
  • @JvmField is compatible with Java, लेकिन const is not.
  • @JvmField is always inlined for faster code.

संदर्भ

प्रश्न 67. What are the two ways to make a coroutine’s computation code cancellable?

  • Call the yield() function or check the isActive property.
  • Call the cancelled() function or check the isActive property.
  • Call the stillActive() function or check the isCancelled property.
  • Call the checkCancelled() function or check the isCancelled property.

संदर्भ

प्रश्न 68. Given the code below, how can you write the line this.moveTo(“LA”) more concisely?

data class Student (val name: String, var location: String) {
  fun moveTo (newLoc: String) { location = newLoc }

}

fun main() {

  Student ("Snow", "Cologne").run {

  this.moveTo ("LA")

}
  • moveTo("LA")
  • ::moveTo("LA")
  • _.moveTo("LA")
  • it.moveTo("LA")

संदर्भ

प्रश्न 69. For the Product class you are designing, you would like the price to be readable by anyone, but changeable only from within the class. Which property declaration implements your design?

  • Option 1
var price: Int = 0
  public get()
  private set
  • Option 2
var price: Int = 0
  private set
  • Option 3
var price: Int = 0
  val set
  • Option 4
val price: Int=0

संदर्भ

क्यू 70. What will happen when you try to build and run this code snippet?

class SpecialFunction : () -> Unit {
  override fun invoke() {
    println("Invoked from an instance.")
  }
}
fun main() {
  try { SpecialFunction()() }
  catch (ex: Exception) { println("An error occurred") }
}
  • A syntax error occurs due to the line SpecialFunction()().
  • The messageAn Error occurredis displayed.
  • The messageInvoked from an instance.is displayed. // the second “()” is equals to .invoke()
  • A compile error occurs. You cannot override the invoke() तरीका.

संदर्भ

प्र71. Which statement declares a variable mileage whose value never changes and is inferred to be an integer?

  • val mileage:Int = 566
  • var mileage:Int = 566
  • val mileage = 566 (ध्यान दें: inferred)
  • const int mileage = 566

संदर्भ

प्र72. What is the preferred way to create an immutable variable of type long?

  • var longInt = 10L
  • const long longInt = 10
  • val longInt = 10L
  • val longInt:Long = 10

प्रश्न 73. Which line converts the binaryStr, which contains only 0s and 1s, to an integer representing its decimal value?

val binaryStr = "00001111"
  • val myInt = toInt(binaryStr)
  • val myInt = binaryStr.toInt("0b")
  • val myInt = binaryStr.toInt()
  • val myInt = binaryStr.toInt(2)

प्रश्न 74. In a Kotlin program, which lines can be marked with a label

  • Any program line can be marked with a label
  • Any statement can be marked with a label
  • Any expression can be marked with a label
  • Only the beginning of loops can be marked with a label
  1. article
  2. संदर्भ

प्रश्न 75. All classes in Kotlin inherit from which superclass?

  • Default
  • Super
  • Any
  • Object

संदर्भ

प्रश्न 76. You have written a function, क्रम से लगाना(), that should accept only collections that implement the Comparable interface. How can you restrict the function?

fun sort(list: List<T>): List <T> {
    return list.sorted()
}
  • जोड़ें <T -> Comparable<T>> between the fun keyword and the function name
  • जोड़ें Comparable<T> between the fun keyword and the function name
  • जोड़ें <T : Comparable<T>> between the fun keyword and the function name
  • जोड़ें <T where Comparable<T>> between the fun keyword and the function name

संदर्भ

प्र77. Kotlin classes are final by default. What does final mean?

  • final means that you cannot use interfaces with this class.
  • final means that this is the only file that can use the class.
  • final means that you cannot extend the class.
  • final classes cannot be used in the final section of a try/catch block.

संदर्भ

प्रश्न 78. You have created an array to hold three strings. When you run the code below, the compiler displays an error. Why does the code fail?

val names = arrayOf<String>(3)
names[3]= "Delta"

  • Arrays use zero-based indexes. The value 3 is outside of the array’s bounds
  • You accessed the element with an index but should have used.set().
  • You declared the array with val but should have used var
  • You cannot changes the value of an element of an array. You should have used a mutable list.

प्र79. If a class has one or more secondary constructors, what must each of them do?

  • Each secondary constructor must call super().
  • Each secondary constructor must call base().
  • Each secondary constructor must directly or indirectly delegate to the primary.
  • Each secondary constructor must have the same name as the class.

संदर्भ

क्यू 80. When you can omit the constructor keyword from the primary constructor?

  • It can be omitted only if an init block is defined.
  • It can be omitted anytime; यह अनिवार्य नहीं है.
  • It can be omitted if secondary constructors are defined.
  • It can be omitted when the primary constructor does not have any modifiers or annotations.
  1. article
  2. संदर्भ

क्यू81. How many different kinds of constructors are available for kotlin classes?

  • दो.
  • none.
  • चार.
  • एक.

संदर्भ

प्रश्न 82. What is the default visibility modifier in Kotlin?

  • संरक्षित
  • private
  • internal
  • जनता

संदर्भ

क्यू 83. The code below compiles and executes without issue, but is not idiomatic kotlin. What is a better way to implement the printlln()?

fun main() {
  val name: String = "Amos"
  val grade: Float = 95.5f
  println("My name is " + name + ". I score " + grade + " points on the last coding quiz.")
}
  • उपयोग new printf().
  • उपयोग string.format बजाय.
  • उपयोग string append बजाय.
  • Use string templates instead.

संदर्भ

प्रश्न 84. You have enum class Signal that represents a state of the network connection. You want to iterate over each member of the enum. Which line of code shows how to do that `?

  • Signal.sequence().
  • Signal.toArray().
  • Signal.values().
  • Signal.toList().

संदर्भ

क्यू85. You’d like to create a multiline string that includes the carriage return character. What should you use to enclose the string?

  • Double quotes(“”).
  • Single quotes(').
  • Tripple quote(“””).
  • Backticks().

संदर्भ

क्यू 86. You want your class member to be visible to subclasses. Which modifier do you use?

  • Public.
  • Protected.
  • Internal.
  • Private.

संदर्भ

क्यू87. Which line of code shows how to create a finite sequence of the numbers 1 प्रति 99 and then convert it into a list?

  • val lessThan99 = generateSequence(1){ यदि (यह < 99) यह + 1 else null }.toList().
  • val lessThan99 = generateSequence(0){ यदि (यह < 99)}.toList().
  • val lessThan99 = generateSequence(1..9){ यदि (यह < 99) यह + 1 else null }.toList().
  • val lessThan99 = listOf{1..99}.asSequence().toList()

संदर्भ

क्यू88. What is wrong with this class definition?

class Empty

  • The class is properly defined, so nothing is wrong with it.
  • The parentheses are missing-it should be declared as class Empty().
  • Empty is a Kotlin keyword, so the code will generate an error when compiled.
  • The curly braces are missing from the declaration of Empty.

संदर्भ

क्यू 89. What is a higher-order function in Kotlin?

  • A higher-order function is a function that returns a value other than Unit.
  • A higher-order function is the function that appears before others in a file.
  • A higher-order function is one that can be stored in a variable.
  • A higher-order function is a function that takes a function as a parameter or returns a function.

संदर्भ

Q90. What is Kotlin?

  • A markup language commonly used for web development.
  • A general-purpose, statically typed, open-source programming language.
  • A relational database management system.
  • A web framework for building dynamic web applications.

प्रश्न91. Who developed Kotlin?

  • यह उन्हें परीक्षण और त्रुटि रणनीति चलाने के बजाय सर्वोत्तम सामग्री देने की अनुमति देता है जो कम रूपांतरण दर का कारण बन सकता है
  • सेब
  • माइक्रोसॉफ्ट
  • JetBrains

प्रश्न92. Which of the following platforms can Kotlin be used for?

  • Android app development
  • Server-side applications
  • Web development
  • Desktop application development

प्रश्न93. What are some key features of Kotlin?

  • Conciseness
  • Null safety
  • Full Java interoperability
  • Smart Cast
  • Extension functions
  • Automatic memory management

प्रश्न94. Why do some developers switch to Kotlin from Java?

  • Kotlin is more concise and cleaner.
  • Kotlin offers useful features not present in Java.
  • Kotlin has good support for Android development.
  • Kotlin is interoperable with Java.
  • All of the above

प्रश्न95. How does Kotlin work on Android?

  • Kotlin code is compiled directly into machine code.
  • Kotlin code is interpreted at runtime.
  • Kotlin code is compiled into Java bytecode and runs on the JVM.
  • Kotlin code is compiled into C++ code for Android.

प्रश्न96. What is the difference between variable declaration with var तथा val in Kotlin?

  • var is used for mutable variables, जबकि val is used for immutable variables.
  • var is used for immutable variables, जबकि val is used for mutable variables.
  • var तथा val are interchangeable; there is no difference.
  • var तथा val are used for completely different purposes.

प्रश्न97. What is the difference between variable declaration with val तथा const in Kotlin?

  • There is no difference; val तथा const can be used interchangeably.
  • val variables must be initialized at compile-time, जबकि const variables can be initialized at runtime.
  • const is used for mutable variables, जबकि val is used for immutable variables.
  • const is used for compile-time constants, जबकि val is used for immutable variables that can be initialized at runtime.

प्रश्न98. How can you create a singleton in Kotlin?

  • By defining a private constructor in the class.
  • By using an object.
  • By declaring a class as final.
  • By implementing the Singleton interface.

प्रश्न99. What is a primary constructor in Kotlin?

  • It is a constructor that can only be called from within the same class.
  • It is a constructor that has no parameters.
  • It is the constructor defined in the class header.
  • It is a constructor that is used for deserialization.

Q100. What do you understand by Null safety in Kotlin?

  • Null safety is a feature that helps prevent null pointer exceptions in code.
  • Null safety is a way to force variables to always have null values.
  • Null safety is a technique for creating nullable variables.
  • Null safety is a feature to allows null values without checks.

संदर्भ

Q101. How can you ensure null safety in Kotlin?

  • By using the !! operator to force variables to be non-null.
  • By using safe calls (?.) and the Elvis operator (?:).
  • By declaring all variables as nullable.
  • Null safety cannot be ensured in Kotlin.

Q102. What is a data class in Kotlin?

  • A class used for storing confidential data.
  • A class designed to hold data with automatically generated methods.
  • A class used to create instances of other classes.
  • A class used to define the structure of data in a database.

Q103. What is the default behavior of Kotlin classes?

  • All classes are open by default.
  • All classes are final by default.
  • All classes are abstract by default.
  • All classes are static by default.

क्यू104. Does Kotlin provide support for primitive data types?

  • नहीं, Kotlin does not provide support for primitive data types like in Java.
  • हां, Kotlin supports primitive data types in addition to objects.
  • Only for certain primitive data types, जैसे कि int.
  • हां, Kotlin provides support for primitive data types like in Java.

क्यू105. Does Kotlin provide support for macros?

  • हां, Kotlin has a rich set of macros for code generation.
  • नहीं, Kotlin does not support macros.
  • हां, Kotlin supports macros for advanced metaprogramming.
  • Macros are not needed in Kotlin as it use a different approach.

Q106. What is the use of the open keyword in Kotlin?

  • NS open keyword is used to declare a variable as mutable.
  • NS open keyword is used to allow a class or function to be subclassed or overridden.
  • NS open keyword is used to specify a class as abstract.
  • NS open keyword is used to indicate that a variable is always null.

Q107. What do you understand by the Ranges operator in Kotlin?

  • The Ranges operator is used to iterate within a range of values.
  • The Ranges operator is used to perform bitwise operations.
  • The Ranges operator is used to concatenate strings.
  • The Ranges operator is used for logical comparisons.

Q108. Where should we use var तथा val in Kotlin?

  • var तथा val can be used interchangeably; there is no difference.
  • उपयोग var for mutable variables and val for immutable variables.
  • उपयोग var for integers and val for strings.
  • उपयोग var for class properties and val for local variables.

Q109. What is the difference between a safe call (?.) and a null check (!!) in Kotlin?

  • The safe call (?.) checks if a variable is null and returns null if it is, while the null check (!!) throws a KotlinNullPointerException if the variable is null.
  • The safe call (?.) and null check (!!) perform the same operation.
  • The safe call (?.) and null check (!!) both return the value of the variable if it is null.
  • The safe call (?.) and null check (!!) are not valid Kotlin operators.

Q110. What is the basic difference between fold तथा reduce in Kotlin?

  • fold takes an initial accumulator value and applies a binary operation to the elements and the accumulator, जबकि reduce uses the first element as the initial accumulator value.
  • fold तथा reduce are equivalent and can be used interchangeably.
  • fold can only be used with collections, जबकि reduce can be used with any data type.
  • fold तथा reduce are both used for filtering elements in a collection.

प्रश्न111. What are the advantages of “जब” इसका कारण ग्रामीण क्षेत्रों से शहरी क्षेत्रों में लोगों का पलायन है “यदि आप त्वरित शिक्षण सिखा रहे हैं” in Kotlin?

  • “जब” in Kotlin is more concise and powerful than “यदि आप त्वरित शिक्षण सिखा रहे हैं” in Java.
  • “जब” in Kotlin is less flexible than “यदि आप त्वरित शिक्षण सिखा रहे हैं” in Java.
  • “जब” in Kotlin can only be used with integers.
  • “जब” in Kotlin is less efficient than “यदि आप त्वरित शिक्षण सिखा रहे हैं” in Java.

Q112. Why does this code snippet not compile?

interface Vehicle

fun main() {
  val myCar = Vehicle()
}
  • Vehicle is an interface.
  • Vehicle needs an init block.
  • The keyword new is missing.
  • Vehicle lacks a constructor.

संदर्भ

प्रश्न 113. What is the difference between a primary constructor and a secondary constructor in Kotlin?

  • A primary constructor is declared in the class header, while a secondary constructor is declared in the class body.
  • A primary constructor can have only one parameter, while a secondary constructor can have multiple parameters.
  • A primary constructor must initialize all of the class’s properties, while a secondary constructor does not have to initialize all of the class’s properties.
  • A primary constructor can only be called once, while a secondary constructor can be called multiple times.

संदर्भ

लेखक

  • हेलेन बस्सी

    नमस्ते, I'm Helena, एक ब्लॉग लेखक जिसे शिक्षा क्षेत्र में ज्ञानवर्धक सामग्री पोस्ट करने का शौक है. मेरा मानना ​​है कि शिक्षा व्यक्तिगत और सामाजिक विकास की कुंजी है, और मैं अपने ज्ञान और अनुभव को सभी उम्र और पृष्ठभूमि के शिक्षार्थियों के साथ साझा करना चाहता हूं. मेरे ब्लॉग पर, आपको सीखने की रणनीतियों जैसे विषयों पर लेख मिलेंगे, ऑनलाइन शिक्षा, व्यवसायिक नीति, और अधिक. मैं अपने पाठकों की प्रतिक्रिया और सुझावों का भी स्वागत करता हूं, इसलिए बेझिझक एक टिप्पणी छोड़ें या किसी भी समय मुझसे संपर्क करें. मुझे आशा है कि आपको मेरा ब्लॉग पढ़ने में आनंद आएगा और यह उपयोगी और प्रेरणादायक लगेगा.

    सभी पोस्ट देखें

के बारे में हेलेन बस्सी

नमस्ते, I'm Helena, एक ब्लॉग लेखक जिसे शिक्षा क्षेत्र में ज्ञानवर्धक सामग्री पोस्ट करने का शौक है. मेरा मानना ​​है कि शिक्षा व्यक्तिगत और सामाजिक विकास की कुंजी है, और मैं अपने ज्ञान और अनुभव को सभी उम्र और पृष्ठभूमि के शिक्षार्थियों के साथ साझा करना चाहता हूं. मेरे ब्लॉग पर, आपको सीखने की रणनीतियों जैसे विषयों पर लेख मिलेंगे, ऑनलाइन शिक्षा, व्यवसायिक नीति, और अधिक. मैं अपने पाठकों की प्रतिक्रिया और सुझावों का भी स्वागत करता हूं, इसलिए बेझिझक एक टिप्पणी छोड़ें या किसी भी समय मुझसे संपर्क करें. मुझे आशा है कि आपको मेरा ब्लॉग पढ़ने में आनंद आएगा और यह उपयोगी और प्रेरणादायक लगेगा.

उत्तर छोड़ दें