Фагим Садыков
Quiz by , created more than 1 year ago

Test about basic knowledge in Kotlin Programming Language

102
0
0
Фагим Садыков
Created by Фагим Садыков over 5 years ago
Close

Kotlin Basics

Question 1 of 11

1

Какой из ниже перечисленных типов не относятся к базовым типам Kotlin

Select one of the following:

  • String

  • Boolean

  • Decimal

  • Int?

  • UShort

Explanation

Question 2 of 11

1

Какой тип у этой переменной:
`val x = 1u`

Select one of the following:

  • UByte

  • Int

  • UInt

  • Нет такого синтаксиса

Explanation

Question 3 of 11

2

Fill the blank space to complete the text.

assertThat("""
͏͏͏͏͏͏͏͏͏͏░░░░:1
͏͏͏͏͏͏͏͏͏͏░░░░:3
""").isEqualTo("""1
2""")

Explanation

Question 4 of 11

3

Fill the blank spaces to complete the text.

Как заставить этот тест действительно выполниться? Чтобы он напечатал Hello и провел успешную проверку?
Внимание - где не ОБЯЗАТЕЛЕН пробел в коде - не ставьте - а то тест не сойдется
Подсказка: когда поймете, дайте ЭТОМУ имя `loop` - иначе опять же тест не сойдется
Подсказка 2: не обязательно заполнять все блоки, если считаете, что там должно остаться пусто - поставьте знак `-`

val data = arrayOf(1,2,4,2,1)
var last = 0

data.forEach{
░░░░last = it
░░░░if(it==4) return
}

println("Hello")
assertThat(last).isEqualTo(4)

Explanation

Question 5 of 11

1

Что мы увидим в выводе консоли?
fun T1():Boolean{print("T1"); return true;}
fun F1():Boolean{print("F1"); return false;}
fun T2():Boolean{print("T2"); return true;}
fun F2():Boolean{print("F2"); return false;}
if(F2()||F1()) print("R1")
if(T1()||F1()||T2())print("R2")
if(T1()&&T2()&&F1()&&F2())print("R3")

Select one of the following:

  • F2T1R2T1T2F1

  • F2R1T1R2T1T2F1

  • F2F1T1F1T2R2T1T2F1F2

  • Часть вызовов могут выполняться в разном порядке по оптимизации компилятора, точного ответа нет

Explanation

Question 6 of 11

1

Можно ли так делать в Kotlin?
val b: Byte = 1
val i: Int = b
val l : Long = i

Select one of the following:

  • Да, как в C# например, хотя в Java не было

  • Да, как и в Java

  • Нет, хотя в Java было

  • Нет и в Java не было

Explanation

Question 7 of 11

1

Fill the blank space to complete the text.

Используйте ровно 2 символа чтобы сошлось
assertThat(33).isEqualTo(21)

Explanation

Question 8 of 11

1

Fill the blank space to complete the text.

Используйте ровно 1 символ чтобы сошлось
assertThat(10001).isEqualTo(10001)

Explanation

Question 9 of 11

1

Это Java
2 << 1
А как на Kotlin?

Select one of the following:

  • 2 shl 1

  • Этот оператор не перенесен

  • Да собственно 2 << 1

Explanation

Question 10 of 11

1

Fill the blank space to complete the text.

Что будет напечатано?
val asc = Array(5, { i -> (i * i).toString() })
asc.forEach { print("$it,") }
>>

Explanation

Question 11 of 11

1

Fill the blank space to complete the text.

В какой строке завалится компилятор? (укажите 0 если ни в какой)
var i = "Hello" //1
var c = i[1] //2
assertThat(c).isEqualTo('e') //3
i[2] = 'z' //4
val i2 = "Hello" //5
i2[2] = 'z' //6

Explanation