wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

LESSON 1-3

Total questions: 60

Worksheet time: 30mins

Name
Class
Date
1.

What is the entry point function of a Kotlin application?

a)

run()

b)

start()

c)

main()

d)

init()

2.

Which function is used to print a line to the standard output?

a)

println()

b)

console.log()

c)

System.out.print()

d)

printLine()

3.

Which keyword declares a read-only (immutable) variable?

a)

static

b)

const

c)

val

d)

var

4.

Which keyword declares a mutable variable that can be changed?

a)

mut

b)

var

c)

let

d)

val

5.

What is the type of the result of 'val x = 5' due to type inference?

a)

Double

b)

Int

c)

String

d)

Float

6.

Which data type represents a value that is either true or false?

a)

Logic

b)

Bit

c)

YesNo

d)

Boolean

7.

How do you insert a variable 'name' directly into a string literal?

a)

"Hello " + name

b)

"Hello $name"

c)

String.format("Hello %s", name)

d)

"Hello {name}"

8.

In Kotlin, 'if' is an expression, which means it returns a value.

a)

False

b)

True

c)

Only in loops

d)

Only for booleans

9.

What is the replacement for the switch statement in Kotlin?

a)

match

b)

case

c)

when

d)

switch

10.

Which collection type cannot be modified after creation?

a)

ArrayList

b)

MutableList

c)

LinkedList

d)

List

11.

Which function creates an array in Kotlin?

a)

Array[]

b)

arrayOf()

c)

list[]

d)

new Array()

12.

What syntax denotes a nullable String type?

a)

String

b)

Optional

c)

Nullable

d)

String?

13.

Which operator allows safely accessing a property of a nullable variable?

a)

->

b)

?.

c)

.

d)

!!

14.

What does the '!!' operator do?

a)

Checks for null safely

b)

Defaults to null

c)

Asserts value is non-null or throws exception

d)

Converts to Int

15.

What is the '?:' operator called?

a)

Elvis operator

b)

Elvis Presley parameter

c)

Safe call operator

d)

Range operator

16.

What tool allows you to run Kotlin code interactively line-by-line?

a)

Compiler

b)

REPL

c)

Debugger

d)

Gradle

17.

On which machine does Kotlin code primarily run in Android?

a)

LLVM

b)

V8

c)

JVM

d)

CLR

18.

Which keyword is used to define a function?

a)

def

b)

method

c)

fun

d)

function

19.

How are function parameters defined in Kotlin?

a)

let name

b)

name: Type

c)

var name

d)

Type name

20.

What symbol indicates a single-line comment?

a)

//

b)

/*

c)

d)

#

21.

What return type indicates a function does not return a useful value?

a)

Null

b)

Unit

c)

Void

d)

Nothing

22.

In 'fun main(args: Array)', what are 'args'?

a)

Command-line arguments

b)

Environment variables

c)

System properties

d)

Function defaults

23.

What feature allows calling 'foo(speed=10)' explicitly naming the parameter?

a)

Labels

b)

Tagging

c)

Default arguments

d)

Named arguments

24.

If a function is defined 'fun drive(speed: Int = 50)', what is 50?

a)

Minimum value

b)

Maximum value

c)

Return value

d)

Default value

25.

Can you mix default and required parameters in a function call?

a)

Only if required come last

b)

Only in constructors

c)

Yes

d)

No

26.

How can 'fun double(x: Int): Int { return x * 2 }' be written more concisely?

a)

fun double(x: Int) = x * 2

b)

val double = x * 2

c)

fun double(x: Int) => x * 2

d)

fun double(x) { x * 2 }

27.

What is an expression that makes a function with no name?

a)

Interface

b)

Lambda

c)

Class

d)

Method

28.

What do we call functions that take other functions as parameters?

a)

Constructors

b)

Super functions

c)

Native functions

d)

Higher-order functions

29.

What is the type syntax for a function taking Int and returning Int?

a)

Int : Int

b)

(Int) -> Int

c)

Int produces Int

d)

Function

30.

What is the implicit name for a single parameter in a lambda?

a)

it

b)

this

c)

arg

d)

that

31.

Which list operation returns elements matching a condition?

a)

reduce

b)

sort

c)

filter

d)

map

32.

Which evaluation strategy do Sequences use?

a)

Urgent

b)

Eager

c)

Lazy

d)

Static

33.

Which list operation transforms every item?

a)

map

b)

find

c)

filter

d)

each

34.

What function converts nested collections into a single list?

a)

merge()

b)

flatten()

c)

combine()

d)

flat()

35.

Which operator passes a named function as a reference?

a)

.

b)

->

c)

::

d)

!!

36.

If a lambda is the last argument, where can it be placed?

a)

Outside the parentheses

b)

It cannot be moved

c)

Before the function name

d)

Inside quotes

37.

What method returns the string representation of an object?

a)

string()

b)

toString()

c)

print()

d)

repr()

38.

Which scope level allows a function to be defined inside another function?

a)

Abstract

b)

Global

c)

Local

d)

Member

39.

Which function returns a new list sorted in ascending order?

a)

sorted()

b)

arrange()

c)

order()

d)

sort()

40.

Which function iterates over every element in a collection?

a)

loop

b)

iterate

c)

next

d)

forEach

41.

Which keyword is used to declare a class?

a)

class

b)

type

c)

struct

d)

object

42.

Can classes have properties declared with 'val' and 'var'?

a)

No

b)

Yes

c)

Only var

d)

Only val

43.

Where is the primary constructor defined?

a)

In a separate file

b)

In the class header

c)

Inside the class body

d)

It is optional

44.

Which block is used for initialization code?

a)

start

b)

init

c)

create

d)

constructor

45.

Which keyword defines an additional (secondary) constructor?

a)

constructor

b)

build

c)

init

d)

new

46.

Which keyword refers to the current instance of the class?

a)

it

b)

self

c)

this

d)

me

47.

What is the default visibility modifier in Kotlin?

a)

private

b)

public

c)

protected

d)

internal

48.

What functions are automatically generated for properties?

a)

clone

b)

Getters and Setters

c)

toString

d)

equals

49.

Which keyword allows a class to be subclassed?

a)

open

b)

public

c)

final

d)

static

50.

In Kotlin, classes are 'final' by default. What does this mean?

a)

They cannot be subclassed

b)

They cannot be instantiated

c)

They are immutable

d)

They are static

51.

Which keyword is used to override a method in a subclass?

a)

override

b)

super

c)

new

d)

overwrite

52.

Which type of class cannot be instantiated directly?

a)

data class

b)

abstract class

c)

final class

d)

open class

53.

What defines a contract that classes must implement?

a)

Interface

b)

Abstract class

c)

Module

d)

Header

54.

How does a class implement an interface 'Shape'?

a)

Shape

b)

inherits Shape

c)

implements Shape

d)

extends Shape

55.

Which keyword marks a class aimed primarily at holding data?

a)

value

b)

data

c)

record

d)

struct

56.

Which method is NOT automatically generated for a data class?

a)

copy()

b)

equals()

c)

random()

d)

hashCode()

57.

Which class stores exactly two values?

a)

Double

b)

Pair

c)

Tuple

d)

Two

58.

Which keyword declares an enumeration?

a)

option

b)

list

c)

choice

d)

enum

59.

Which keyword creates a Singleton?

a)

static

b)

instance

c)

object

d)

single

60.

What object inside a class allows static-like member access?

a)

Companion object

b)

Global object

c)

Static block

d)

Shared object