CIS 386 Android App Development Quiz 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

b.False

Array indices start with index 1: a.True b.False

a.True

Constructors facilitate easy instantiation of class objects. a.True b.False

b.X in range

How can we check if a value is in a range? a.Range contains x b.X in range c.Range has x d.X of Range

a.For (x in 5..15)

How can you create a range of number between 5 and 15 in Kotlin? a.For (x in 5..15) b.For (5..15) c.For (5 to 15) d.For (x in 5 to 15)

c.Val num=2.8

How can you create a variable with the floating number 2.8? a.Double num=2.8 b.Float num=2.8 c.Val num=2.8 d.Num=2.8 float

a.Val num=5

How can you create a variable with the numeric value 5? a.Val num=5 b.Num=5 c.Num=5 int d.Int num=5

a.myObj.myFun()

How do we call a function myFun() in a class using the class object myObj. a.myObj.myFun() b.myFun().myObj c.myObj.myFun d.myObj myfun()

a.functionName()

How do you call a function in Kotlin? a.functionName() b.call functionName c.Function-> functionName d.functionName:call

b.myFuntction()

How do you call a function in Kotlin? a.myFunction[] b.myFuntction() c.(myFunction) d.myFunction;

b./* This is a comment*/

How do you create a multi-line comment in Kotlin? a.// This is a comment// b./* This is a comment*/ c./*This is a comment d.## This is a comment

a.val str: String = "Hello, World!"

How do you declare a String in Kotlin? a.val str: String = "Hello, World!" b.String str = "Hello, World!" c.val str = String("Hello,World!") d.String str = new String("Hello, World!")

a.val numbers = arrayOf(1,2,3)

How do you declare an array of integers in Kotlin? a.val numbers = arrayOf(1,2,3) b.val numbers = listOf(1,2,3) c.val numbers = [1,2,3] d.val numbers = Array(3) {0,1,2}

b.val

How do you define a variable in Kotlin that cannot be reassigned? a.var b.val c.const d.Final

a. //This is a comment

How do you insert COMMENTS in Kotlin code? a. //This is a comment b./*This is a comment c./This is a comment d.#This is a comment

a.For (x in y)

How do you start writing a loop in Kotlin, to loop through arrays? a.For (x in y) b.For x c.For x in y d.For (x)

c.While(x<y)

How do you start writing a while loop in Kotlin? a.While x<y then b.While x<y c.While(x<y) d.If x>y while

c.If(x>y)

How do you start writing an if statement in Kotlin? a.If x>y then b.If x>y c.If(x>y) d.If x>y()

b.False

In Kotlin, code statements must end with a semicolon (;). a.True b.False

c.Both a and b

Is Kotlin a functional language or an object-oriented one? a.Functional b.Object-Oriented c.Both a and b d.Kotlin is neither functional nor object-oriented.

a.True

Kotlin is a case sensitive language. a.True b.False

b.True

The attribute of a class and its corresponding parameter in constructor function can have the same name. a.False b.True

b.Boolean

The following datatype represents logical values such as true and false. a.Logical b.Boolean c.Double d.String

a.False

The value of a string variable must be surrounded by single quotes. a.False b.True

b.The arrayOf() function

To create an array in Kotlin, we use a.[] b.The arrayOf() function c.None of the above d.{}

c.A statically-typed programming language for the JVM, Android, and browser.

What is Kotlin? a.A new version of Java. b.A JavaScript framework. c.A statically-typed programming language for the JVM, Android, and browser. d.A database management system.

d. Println("Hello World")

What is a correct syntax to output "Hello World" in Kotlin? a. Cout<<"Hello World"; b. System.out.printline("Hello World") c. Console.WriteLine("Hello World") d. Println("Hello World")

c.Val myObj = MyClass()

What is the correct way to create an object called myObj of MyClass? a.Main myObj = new MyClass(); b.MyClass.new myObj c.Val myObj = MyClass() d.myObj = MyClass()

a.Var i: int=42

What is the correct way to declare a variable of integer type in Kotlin? a.Var i: int=42 b.Let i =42 c.Int i =42 d.I =42

b.B can never become null

What is the difference beteween a and b? Var a:String?="kotlinQuiz" Var b:string="kotlinQuiz" a.B is final and cannot be changed b.B can never become null c.A is volatile as in java d.A is final and cannot be changed

d.Val is immutable while variable is mutable.

What is the difference between val and var in Kotlin? a.Variables declared with var are final, those with val are not. b.Variables declared with val can only be accessed within a class. c.Var is scoped to the nearest function block and val is scoped to the nearest enclosing block. d.Val is immutable while variable is mutable.

b.Fun main(){}

What is the entry point for Kotlin application? a.Fun static main(){} b.Fun main(){} c.Function main(){} d.Public static void main(){}

c.Parameter

What is the fname known as in the following code: fun myFunction(fname: String) a.Range b.Inherit c.Parameter d.Override

a.Hello world!It is a beautiful day outside. Time to go out and explore.

What is the output of the following code Fun main(){ Print("Hello world!") Println("It is a beautiful day outside.") Print("Time to go out and explore.") } a.Hello world!It is a beautiful day outside. Time to go out and explore. b.Hello world! It is a beautiful day outside. Time to go out and explore. c.Hello world!It is a beautiful day outside.Time to go out and explore. d.The above code throws error.

c.True

What is the output of the following code: println(5>3&&5<10)? a.2 b.False c.True d.5

b.True

What is the output of the following piece of code? Val x = 10 Val y = 9 Println(x>y) a.False b.True c.10 d.Greater

c.Fun sum(a: Int, b: Int)

Which is a valid function declaration in Kotlin? a.Function sum(a: Int, b: Int): Int b.Int sum(a: Int, b: Int) c.Fun sum(a: Int, b: Int) d.Int sum(int a, int b)

d.Class

Which keyword is used to create a class in Kotlin? a.Class() b.className c.Myclass d.Class

b.Fun

Which keyword is used to declare a function? a.Function b.Fun c.Decl fun d.Create fun

a.Return

Which keyword is used to return a value inside a function? a.Return b.Void c.Break d.Get

c.both a and b

Which keywords are used to handle conditional statements in Kotlin? a.if b.when c.both a and b d.none of the above

d.Double Float

Which of the following is not a datatype in Kotlin? a.Short b.Long c.Double d.Double Float

b.Kotlin can easily call Java code and Java can easily call Kotlin code.

Which of the following statements is true? a.Kotlin can easily call Java, but Java cannot access code written in Kotlin. b.Kotlin can easily call Java code and Java can easily call Kotlin code. c.While Kotlin runs on the JVM, it cannot interoperate with Java. d.None of the statements are true

c.until loop

Which of these is not a loop structure in Kotlin? a.for loop b.while loop c.until loop d.do-while loop

b.==

Which operator can be used to compare two values? a.= b.== c.>< d.<>

a.The + sign

Which operator is used to add together two values? a.The + sign b.The & sign c.The * sign d.The ++ sign

c.JVM(Java Virtual Machine)Bytecode

Which platform does Kotlin primarily target? a.Python Bytecode b.Javascript c.JVM(Java Virtual Machine)Bytecode d.PHP

a.The length property

Which property can be used to find the length of a string? a.The length property b.The sizeOf property c.The len property d.The size property

d.Break

Which statement is used to stop a loop? a.Stop b.Exit c.Void d.Break

a.$

Which symbol is used for string templates/interpolation? a.$ b. . c.& d.*

a.no

Will the following code compile? 1. Val myInt = 10 2. Var myLong = 22L myLong = myInt a.no b.yes


Set pelajaran terkait

Chapter 2: Ethics and Social Responsibility in Business

View Set

Fair Debt Collections Practices Act (FDCPA)

View Set

Module 9 Test: Linux installation and configuration

View Set

Catcher in the Rye 1-6 Reading Questions

View Set

Practice Test 5: EA Exam - Practice Test 5 Part 2

View Set

LSAT Logical Reasoning Question Types and Examples

View Set

Chapter 15 - Air Traffic Services

View Set

Science For Sustainable Development Final Exam Study

View Set