Login
Sign up
Categories
IT & Programming
Design & Multimedia
Writing & Translation
Sales & Marketing
Admin Support
Engineering & Manufacturing
Finance & Management
Website Designing & Development
Database Management
Networking & Troubleshooting
Aviation & Aerospace
Softwares & Applications
Stocks & Investments
Electronics & Appliances
Online Tools
General Knowledge & Aptitude
Mathematics
Educational Subjects & Courses
Business & Organization
Health & Wellbeing
Culture & Ethics
IT Field Knowledge & Experience
Languages & Communication
Entrepreneurship & Leadership
Economics & Development
Mass Communication & Media
Research Methods & Evaluation
Public Relations & Dealings
Educational Methods and Research
Educational Subjects & Techniques
Crime & Justice
Governments & Policies
Cyber Security & Ethical Hacking
Hospitality & Tourism
Soft Skills & Personal Management
Transportation & Driving Rules
Forest and Nature
Religion
Skill Assessment
MCQs
PDFs
Login
Sign up
Categories
IT & Programming
Design & Multimedia
Writing & Translation
Sales & Marketing
Admin Support
Engineering & Manufacturing
Finance & Management
Website Designing & Development
Database Management
Networking & Troubleshooting
Aviation & Aerospace
Softwares & Applications
Stocks & Investments
Electronics & Appliances
Online Tools
General Knowledge & Aptitude
Mathematics
Educational Subjects & Courses
Business & Organization
Health & Wellbeing
Culture & Ethics
IT Field Knowledge & Experience
Languages & Communication
Entrepreneurship & Leadership
Economics & Development
Mass Communication & Media
Research Methods & Evaluation
Public Relations & Dealings
Educational Methods and Research
Educational Subjects & Techniques
Crime & Justice
Governments & Policies
Cyber Security & Ethical Hacking
Hospitality & Tourism
Soft Skills & Personal Management
Transportation & Driving Rules
Forest and Nature
Religion
Skill Assessment
MCQs
PDFs
Login
Sign up
Skill Assessments
>
IT & Programming
>
Kotlin Skill Assessment
>
Quiz # 1
Kotlin Quiz # 1
Instructions
Quiz:
Kotlin Quiz # 1
Subject:
Basic Keynote
Total Questions:
30 MCQs
Time:
30 Minutes
Note
Do not refresh the page while taking the test.
Results along with correct answers will be shown at the end of the test.
Start Quiz
Kotlin Quiz # 1
End Quiz
Question
1
of 30
00:00
Kotlin interfaces and abstract classes are very similar. What is one thing abstract class can do that interfaces cannot?
Only abstract classes are inheritable by subclasses
Only abstract classes can inherit from multiple superclasses
Only abstract classes can have abstract methods
Only abstract classes can store state
Inside an extension function, what is the name of the variable that corresponds to the receiver object
The variable is named it
The variable is named this
The variable is named receiver
The variable is named default
What is the entry point for a Kotlin application?
Fun static main(){}
Fun main(){}
Fun Main(){}
Public static void main(){}
You are writing a console app in Kotlin that processes test entered by the user. If the user enters an empty string, the program exits. Which kind of loop would work best for this app? Keep in mind that the loop is entered at least once
A do..while loop
A for loop
A while loop
A forEach loop
You have started a long-running coroutine whose job you have assigned to a variable named task. If the need arose, how could you abort the coroutine? val task = launch { // long running job}
Task.join()
Task.abort()
Job.stop()
Task.cancel()
You are attempting to assign an integer variable to a long variable, but Kotlin compiler flags it as an error. Why?
You must wrap all implicit conversion in a try/catch block
You can only assign Long to an Int, not the other way around
There is no implicit conversion from Int to Long
All integers in Kotlin are of type Long
The function typeChecker receiver a parameter obj of type Any. Based upon the type of obj, it prints different messages for Int, String, Double, and Float types; if not any of the mentioned types, it prints "unknown type". What operator allows you to determine the type of an object?
Instanceof
Is
Typeof
As
This code does not print any output to the console. What is wrong? firstName?.let { println("Greeting $firstname!")}
FirstName?.let { println(
A null pointer exception is thrown
FirstName is equal to null
FirstName is equal to an empty string
FirstName is equal to Boolean false
Which line of code shows how to display a nullable string's length and shows 0 instead of null?
Println(b!!.length ?: 0)
Println(b?.length ?: 0)
Println(b?.length ?? 0)
Println(b == null? 0: b.length)
In the file main.kt, you are filtering a list of integers and want to use an already existing function, removeBadValues. What is the proper way to invoke the function from filter in the line below? Val list2 = (80..100).toList().filter(_____)
::removeBadValues
GlobalScope.removeBadValues()
Mainkt.removeBadValues
RemoveBadValues
Which code snippet correctly shows a for loop using a range to display "1 2 3 4 5 6"?
for(z in 1..7) println("$z ")
for(z in 1..6) print("$z ")
for(z in 1 to 6) print("$z ")
for(z in 1..7) print("$z ")
You are upgrading a Java class to Kotlin. What should you use to replace the Java class's static fields?
An anonymous object
A static property
A companion object
A backing field
Your code need to try casting an object. If the cast is not possible, you do not want an exception generated, instead you want null to be assigned. Which operator can safely cast a value?
As?
??
Is
As
Kotlin will not compile this code snippet. What is wrong? class Employee class Manager : Employee()
In order to inherit from a class, it must be marked open
In order to inherit from a class, it must be marked public
In order to inherit from a class, it must be marked sealed
In order to inherit from a class, it must be marked override
Which function changes the value of the element at the current iterator location?
Change()
Modify()
Set()
Assign()
What three methods does this class have? Class Person
Equals(), hashCode(), and toString()
Equals(), toHash(), and super()
Print(), println(), and toString()
Clone(), equals(), and super()
Which is the proper way to declare a singleton named DatabaseManager?
Object DatabaseManager {}
Singleton DatabaseManager {}
Static class DatabaseManager {}
Data class DatabaseManager {}
In order to subclass the Person class, what is one thing you must do? abstract class Person(val name: String) { abstract fun displayJob(description: String)}
The subclass must be marked sealed
You must override the displayJob() method
You must mark the subclass as final
An abstract class cannot be extended, so you must change it to open
Your function is passed by a parameter obj of type Any. Which code snippet shows a way to retrieve the original type of obj, including package information?
Obj.classInfo()
Obj.typeInfo()
Obj::class.simpleName
Obj::class
Which is the correct declaration of an integer array with a size of 5?
Val arrs[5]: Int
Val arrs = IntArray(5)
Val arrs: Int[5]
Val arrs = Array
(5)
You have created a class that should be visible only to the other code in its module. Which modifier do you use?
Internal
Private
Public
Protected
Kotlin has two equality operators, == and ===. What is the difference?
== determines if two primitive types are identical. === determines if two objects are identical
== determines if two references point to the same object. === determines if two objects have the same value
== determines if two objects have the same value. === determines if two strings have the same value
== determines if two objects have the same value. === determines if two references point to the same object
Which snippet correctly shows setting the variable max to whichever variable holds the greatest value, a or b, using idiomatic Kotlin?
Val max3 = a.max(b) (Extension Function is One of the idiomatic Solutions in Kotlin)
Val max = a > b ? a : b
Val max = if (a > b) a else b
If (a > b) max = a else max = b
You have an enum class Signal that represents the state of a network connection. You want to print the position number of the SENDING enum. Which line of code does that?
Enum class Signal { OPEN, CLOSED, SENDING }
Println(Signal.SENDING.position())
Println(Signal.SENDING.hashCode())
Println(Signal.SENDING)
Println(Signal.SENDING.ordinal)
You would like to know each time a class property is updated. Which code snippet shows a built-in delegated property that can accomplish this?
Delegates.watcher()
Delegates.observable()
Delegates.rx()
Delegates.observer()
What is the correct way to initialize a nullable variable?
Val name = null
Var name: String
Val name: String
Val name: String? = null
Which line of code is a shorter, more idiomatic version of the displayed snippet? val len: Int = if (x != null) x.length else -1
Val len = x?.let{x.len} else {-1}
Val len = x!!.length ?: -1
Val len:Int = (x != null)? x.length : -1
Val len = x?.length ?: -1
The Kotlin .. operator can be written as which function?
A.from(b)
A.range(b)
A.rangeTo(b)
A.to(b)
In this code snippet, why does the compiler not allow the value of y to change? For(y in 1..100) y+=2
Y must be declared with var to be mutable
Y is an implicitly immutable value
Y can change only in a while loop
In order to change y, it must be declared outside of the loop
This code snippet compiles without error, but never prints the results when executed. What could be wrong? Val result = generateSequence(1) { it + 1 }.toList(); Println(result)
The sequence lacks a terminal operation.
The sequence is infinite and lacks an intermediate operation to make it finite.
The expression should begin with generateSequence(0).
The it parameter should be replaced with this.
Submit Test
Prev Question
ABCd
Next Question
Kotlin Skill Assessment
Login to see Skill Score (It's Free)
Your Skill Level:
Poor
Retake Quizzes to improve it
Start Assessment
Kotlin Skill Assessment
Login to see Skill Score (It's Free)
Your Skill Level:
Poor
Retake Quizzes to improve it
Start Assessment