Formative 1

studied byStudied by 0 people
0.0(0)
get a hint
hint

True

1 / 46

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

47 Terms

1

True

Boolean type values in Kotlin can only have true or false values

  • True

  • False

New cards
2

24

The Float data type in Kotlin can have up to _____ significant bits.

  • 53

  • 24

  • 16

  • 32

New cards
3

for

The ______ control flow statement iterates through anything that provides an iterator.

  • while

  • when

  • for

  • if

New cards
4

package

What keyword is used to declare a package?

  • package

  • pckg

  • pkg

  • pack

New cards
5

val

What keyword is used to declare immutable variables (constants) in Kotlin?

  • var

  • None of the other choices is correct.

  • val

  • dec

New cards
6

True

The when control structure can replace if..else..if chain when used without putting any argument.

  • True 

  • False

New cards
7

False

Using if statement as an expression requires an else clause. False

  • True 

  • False

New cards
8

2.5

  1. What is the output of the following code:

      mc015-1.jpg

  • 2

  • 2.5

  • Error, data type of variables is not the same

  • Will not display any output

New cards
9

All the other choices are correct

  1. Which of the following statements will show the output: The value of x is:

  • mc026-3.jpg

  • All the other choices are correct

  • mc026-2.jpg

  • mc026-1.jpg

New cards
10

Long

What is the data type of the variable declared below: val num = -42L.

  • Short

  • Byte

  • Long

  • Int

New cards
11

triple quotes

What symbol is used to define a raw string?

  • a pair of single quotes

  • three single quotes

  • a pair of double quotes

  • triple quotes

New cards
12

True

The if control structure in Kotlin is considered as an expression which means it is expected to return a value.

  • True

  • False

New cards
13

Code will execute and will print: 1 2 3 4 6 7 8 9 10

  1. Analyze the code below:

mc035-1.jpg

  • Error in line 2.

  • Code will execute and will print: 1 2 3 4 5 6 7 8 9 10

  • Code will execute and will print: 1 2 3 4 6 7 8 9 10

  • Error in line 3.

New cards
14

plus ( + )

What symbol is used for String concatenation in Kotlin?

  • period ( . )

  • plus ( + )

  • comma ( , )

  • ampersand ( & )

New cards
15

Code will execute and will print: 1 2 3 4

Analyze the code below:

mc036-1.jpg

  • Code will execute and will print: 1 2 3 4 6 7 8 9 10

  • Code will execute and will print: 1 2 3 4 5 6 7 8 9 10

  • Code will execute and will print: 1 2 3 4

  • Error in line 3.

New cards
16

False

You can use escape characters in a raw string.:

  • True

  • False

New cards
17

True

We can put underscores in the initial values of numeric type variables, e.g. val x = 1_234.

  • True 

  • False

New cards
18

True

The symbol $ is used when creating string templates.

  • True

  • False

New cards
19

||, &&, !

Which of the following shows the Kotlin built-in Boolean operations?

  • ||, &&, !!

  • |, &, !

  • ||, &&, !

  • |, &, !!

New cards
20

False

The return jump expression terminates the nearest enclosing loop.

  • True

  • False

New cards
21

The value is: 7.

  1. Analyze the code below and determine its output:

  • The value is $7.

  • The value is: x + 2.

  • The value is: ${x + 2}.

  • The value is: 7.

New cards
22

It will execute normally and prints: 6 5 2

What will happen if the code below is executed?

  • It will execute normally and prints: 6 5 2

  • Error in line 4, the for statement needs more arguments.

  • Error in line 2, it is not the correct way of defining arrays.

  • It will execute normally and prints: 3 9

New cards
23

F or f

To explicitly define a Float type variable, you have to add a suffix ____ after the initial value.

  • Fl or fl

  • Float or float

  • F or f

  • Ft or ft

New cards
24

The sum is: 13.4

  1. What is the output of the code below?

  • The sum is: 13

  • Error, variable x and y does not have the same data type

  • Error, statements do not have semicolons

  • The sum is: 13.4

New cards
25

2

  1. What is the output of the code below?

  • Error, data type of variables is Int

  • Will not display any output

  • 2.5

  • 2

New cards
26

2,147,483,648 to 2,147,483,647

What is the range value of the Int data type?

  • 2,147,483,648 to 2,147,483,647

  • -2,147,483,647 to 2,147,483,648

  • -2,147,483,647 to 2,147,483,647

  • -2,147,483,648 to 2,147,483,648

New cards
27

$

We can use template expressions in string by using _____ symbol followed by either an identifier or an expression delimited by curly braces.

  • &

  • @

  • ^

  • $

New cards
28

break

What jump expression terminates the nearest enclosing loop?

  • break

  • return

  • goto

  • continue

New cards
29

Another String

  1. What is the output of the code below?

  • Will not display any output.

  • String Another

  • Another $x

  • Another String

New cards
30

6

How many numerical data types are there in Kotlin?

  • 6

  • 4

  • 5

  • 3

New cards
31

8

The Byte data type has a size of _____ bits.

  • 16

  • 8

  • 32

  • 4

New cards
32

trimMargin()

What function is used in removing leading whitespaces in a raw string?

  • trimLead()

  • trimWhitespace()

  • trim()

  • trimMargin()

New cards
33

when

This statement replaced the switch statement in other programming languages.

  • when

  • then

  • choice

  • select

New cards
34

|First Name: Joseph

|Last Name: Calleja

  1. What is the output of the following code?

  • Error, the code uses unknown symbols to delimit a string value.

  • |First Name: Joseph

     |Last Name: Calleja

  • Error, the code uses and unknown function, trimMargin()

  • First Name: Joseph

                               Last Name: Calleja

New cards
35

..

  1. When iterating through a range of numbers using the for statement, we use the range expression which is represented by the symbol ________.

  • “”

  • ..

  • [ ]

  • ( )

New cards
36

Double

All variables initialized with a fractional number will infer the _____ data type.

  • Short

  • Double

  • Float

  • Int

New cards
37

It will run and will print: Grade is: Failed

Analyze the following code:

  • It will run and will print: Grade is: Failed

  • It will run but there will be no output.

  • It will not run due to an error in the condition in the if statement.

  • It will run and will print: Grade is: Passed

New cards
38

True

while and do..while loops are also available in Kotlin and are used the same way they are used in other programming languages.

  • True

  • False

New cards
39

False

String is a mutable data type.

  • True

  • False

New cards
40

False

Characters are treated as numbers in Kotlin.

  • True

  • False

New cards
41

The program will execute, and prints Can now vote.

  1. Analyze the code below:

mc030-1.jpg

  • The program has an error in line 5, !in is not a valid statement.

  • The program has an error in line 7, keyword else is not used in when statement.

  • The program will execute, and prints Can now vote.

  • The program will execute but will not print anything.

New cards
42

True

Using if statement as an expression requires an else clause.

  • True

  • False

New cards
43

True

String templates can be used in raw strings.

  • True

  • False

New cards
44

False

Individual characters in a Sting-type value can be accessed by indexing operation.

  • True

  • False

New cards
45

L or l

If you want to explicitly declare a variable with a Long data type, your have to append a suffix _______ to its initial value.

  • LNG or lng

  • L or l

  • Lng or lng

  • Long or long

New cards
46

False

Raw strings can contain escape code characters.

  • True

  • False

New cards
47

4th

  1. Which of the following codes correctly declares an Int-type array of size 5, initializes the array with values 1, 2, 3, 4, 5 and prints the values vertically?

  • mc024-2.jpg

  • mc024-3.jpg

  • mc024-4.jpg

  • mc024-1.jpg


New cards

Explore top notes

note Note
studied byStudied by 27 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 6 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 8 people
Updated ... ago
4.0 Stars(1)
note Note
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 13487 people
Updated ... ago
4.9 Stars(60)

Explore top flashcards

flashcards Flashcard117 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(2)
flashcards Flashcard44 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard160 terms
studied byStudied by 15 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard42 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard92 terms
studied byStudied by 105 people
Updated ... ago
5.0 Stars(3)
flashcards Flashcard30 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard59 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard53 terms
studied byStudied by 28 people
Updated ... ago
5.0 Stars(1)