Kotlin Flashcards

1
Q

modern but already mature programming language designed to make developers happier

A

kotlin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Kotlin was built by software development tool creators ___ in 2010

A

JetBrains

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why use ‘Kotlin‘?

A
  • Kotlin is fully compatible with Java
  • Kotlin works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
  • Kotlin is concise and safe
  • Kotlin is easy to learn, especially if you already know Java
  • Kotlin is free to use Big community/support
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the IDE used for Kotlin (in our case)?

A

IntelliJ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

is the entry point for a Kotlin application

A

Function Declaration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

This keyword is short for “function” and is used to declare a function in Kotlin.

A

fun

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

This is the name of the function. By convention, it’s called main and serves as the entry point for the program

A

main

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do we write comments?

A

/**/ - multiline comments
// - one liner comments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

is used to declare a mutable variable, which means its value can be changed or reassigned after it’s initially assigned

A

var

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

is used to declare an immutable variable, which means its value cannot be changed or reassigned after it’s initially assigned. It’s essentially a constant.

A

val

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Represents 32-bit signed integers

A

int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Represents 64-bit signed integer

A

long

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Represents 16-bit signed integers

A

short

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Represents 8-bit signed integers

A

byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

epresents 32-bit floating-point numbers

A

float

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Represents 64-bit floating-point numbers

A

double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Represents true or false values

A

boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Represents a single character

A

char

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Represents a sequence of characters

A

string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

2 ways to input in kotlin

A

1.) val scanner = Scanner(System.in)
val name = scanner.next()
2.) val name = readLine()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

are used to assign values to variables

A

Assignment operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

are used to compare two values, and returns a Boolean value: either true or false

A

Comparison operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

are used to determine the logic between variables or values

A

Logical operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

(also called as Type casting) refers to changing the entity of one data type variable into another data type.

A

Type conversion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

how to type cast?

A

varname.toString()
varname.toFloat()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

An expression consists of __,___,___ etc that produce a single value

enumerate 3

A

variables, operators, methods calls

27
Q

A ___ is the syntactic unit of any programming language that expresses some action to be carried out. A program is formed by the sequence of one or more statements.

A

statement

28
Q

A ___ is a section of software code enclosed with curly braces ({…}). A block can consist of one or more statements, preceded by the declarations of variables.

A

block

29
Q

The ___ specifies a block of code and executes it only if a given condition is true. Otherwise, it ignores the block of code.

A

if statement

30
Q

loops

The codes inside the body of ___ is executed once (without checking the testExpression). Then, the test expression is checked.

A

do
construct

31
Q

loops

If the test expression is evaluated to
true, codes inside the body of the loop are ___, and test expression is evaluated again. This process goes on until the test expression is evaluated to false.

A

executed

32
Q

There are 2 ways to use break and continue in Kotlin programming.

A

a. With Label(Labeled).
b. Without Label(UnLabeled)

33
Q

is used to come out of a loop once a certain condition is met. This loop could be a for, while or do…while loop.

A

labeled break statement

34
Q

Kotlin labeled break statement is used to terminate the specific loop. This is done by using break expression with what format?

A

@ sign followed by label name (break@LabelName)

35
Q

breaks the loop iteration in between (skips the part next to the continue statement till end of the loop) and continues with the next iteration in the loop.

A

Labeled continue statement

36
Q

Kotlin labeled continue statement is used to skip the part of a specific loop. This is done by using continue expression with what format?

A

@ sign followed by label name (continue@LabelName)

37
Q

When break expression encounters in a program it terminates to nearest enclosing loop

A

unlabeled break statement

38
Q

is to used to exit the loop when it satisfies a specific condition without checking the test expression. Then, transfers the control to the following statement of while block

A

Unlabelled break

39
Q

In do-while loop also we can use the ___ to exit the loop without checking the test expression

A

break expression

40
Q

Continue is used to repeat the loop for a specific condition. It skips the following statements and continues with the next iteration of the loop.

A

Kotlin unlabelled continue

41
Q

___ are used to store multiple values in a single variable, instead of creating separate variables for each value.

A

Arrays

42
Q

To create an array, use the __ function, and place the values in a comma-separated list inside it.

A

arrayOf()

43
Q

format of array creation?

A

val arrayName = arrayOf(ElementType)

44
Q

You can access an array element by referring to the ___, inside square brackets.

A

index number

45
Q

You can use the __ operator to check if an element exists in an array

A

in

46
Q

You can loop through the array elements with the __

A

for loop

47
Q

contain a group of related statements that perform specific tasks. They are designed to be reusable, eliminating the need to rewrite the piece of code every time it is used.

A

Functions

48
Q

Built-in functions that are immediately ready for use. The Kotlin Standard Library has several packages for different uses

A

Kotlin Standard Library Functions

49
Q

Give examples of Kotlin Standard Library Functions

A
  • kotlin
  • kotlin.annotation
  • kotlin.browser
  • kotlin.collections
  • kotlin.js
  • kotlin.jvm
  • kotlin.jvm.optionals
  • kotlin.math
50
Q

as the name implies, functions that you define and write yourself.

A

User-defined Functions

51
Q

also known as formal arguments, are placeholders for input values (arguments) that the function will use.

A

Parameters

52
Q

In Kotlin, parameters are declared using the Pascal notation.

A

name:type

53
Q

If the function has a return type, a ___ must be used. The return statement signals the end of the function definition. The variable returned is the output of the function.

A

return statement

54
Q

___ are called using their identifier followed by a __ which may contain arguments based on its declaration

A

Functions, set of parentheses “()”

55
Q

are values that were assigned to parameters at the function’s definition. This allows us to call functions with missing arguments. If an argument is not passed to a parameter with a default value, it will use the default value instead.

A

Default arguments

56
Q

allow you to specify arguments using the name of the parameter instead of relying on its position.

A

Named Arguments

57
Q

A ___ is a function that calls
itself, either directly or
indirectly, to solve a problem. Recursion is
a powerful technique used in
programming when a problem can be broken down into smaller, similar subproblems.

A

recursive function

58
Q

3 advantages of recursive function

A
  1. Improved code readability and maintainability
  2. Easy implementation of algorithms
  3. Reusability
59
Q

2 disadvantages of recursive functions

A
  1. Increased memory usage
  2. Performance
60
Q

A ___ is a concise way to represent an anonymous function (a function that has no name) that can be used as a variable, argument, or return value in higher-order functions.

A

lambda expression

61
Q

___ are a fundamental feature of functional programming in Kotlin and are used extensively when working with functions, collections, and other higher-order constructs.

A

Lambda expressions

62
Q

lambda format

A

{parameters -> body}

always between curly braces!

63
Q

are a powerful feature that allows you to treat functions as first-class citizens, meaning you can pass functions as arguments, return them from other functions, and assign them to variables.

A

Higher-order functions

64
Q

enable functional programming paradigms and are a fundamental part of the language’s expressiveness and flexibility.

A

Higher-order functions