days
-1
-3
hours
-1
-6
minutes
-5
-5
seconds
0
-3
search
Trivial pursuit

How well do you know your Kotlin trivia?

Aswin Shrestha
Angular
© Shutterstock / Frazao

Our pub quiz series continues with another look at a new programming language. This time, we’re testing your knowledge about Kotlin, the darling of Android that was recently promoted to a first-class language status. Do you know everything there is to know about this fresh-faced static language?

After the recent Google I/O announcement of Kotlin being an official language for Android, it has rose tremendously in popularity. Developers love Kotlin because it is expressive, safe, concise and fun to code with. Kotlin plays well with the Java programming language and the effortless interoperation between the two languages has been a large part of Kotlin’s appeal.

Let’s get down to business and test your knowledge of Kotlin trivia!

1.  Who is the creator of Kotlin?
a) Google
b) JetBrains
c) Oracle
d) Microsoft

2.  Which open source license is Kotlin released under?
a) MIT License (MIT)
b) GNU General Public License (GPL)
c) Apache License 2.0 (Apache 2.0)
d) FreeBSD License (BSD-2-Clause)

3.  Does Kotlin work only for Java?
a) Yes
b) No

4.  Is Kotlin backward-compatible?
a) Yes
b) No

SEE MORE: Kotlin is now a first-class language on Android

5.  Does Kotlin allow macros?
a) Yes
b) No

6.  Which of these is used to handle null exceptions in Kotlin?
a) Range
b) Sealed Class
c) Elvis Operator
d) Lambda function

7. What is the default behavior of Kotlin classes?
a) All classes are public.
b) All classes are sealed.
c) All classes are final.
d) All classes are abstract.

8.  Which of these is true for Kotlin variables?
a) val corresponds to final variable in Java.
b) var cannot be changed.
c) val can be changed.
d) All variables are immutable by default.

SEE MORE: Why learn Kotlin [Infographic]

Answers:

1.  b) JetBrains. Kotlin was created by JetBrains, a company renowned for creating development tools for professionals.

2.  c) Apache License 2.0 (Apache 2.0). JetBrains is open sourced Kotlin under Apache 2 License. You can edit and distribute all development code and tools related to Kotlin as you please, without renaming it as your own intellectual property.

3.  b) No. After starting out with Java & Android, Kotlin has already expanded to JavaScript. They are currently working on Native, which compiles to native code directly without the use of any virtual machines.

4.  a) Yes. However, the compatibility exists only until a major release of Kotlin. So, if the current version of Kotlin is 1.1.4, the deprecation takes place in 1.7, it is then elevated to an error in 1.8 and the deprecated code is deleted after 2.0.

5.  b) No. It’s hard to optimize and test code containing macros. Hence, the developers of Kotlin decided not to include it in the language.

6.  c) Elvis Operator. You can use Elvis operator (?:) in Kotlin to say “if object is not null, use it, otherwise use some non-null value”.

7.  c) All classes are final. All Kotlin classes are final by default. This is because the initial design of Kotlin included multiple inheritance for classes, and an open class was a lot more expensive bytecode-wise than a final class.

8.  a) val corresponds to final variable in Java. Both val and var are used to create variables in Kotlin. However, using val makes a variable immutable, i.e. you cannot change its value once initialized. This corresponds to final variable in Java.

Results:

How well did you do? Do you know your Kotlin trivia?

0-3 correct: You’re just a Kotlin beginner. Time to go through a comprehensive tutorial on Kotlin and do a bit more studying. Head over to Programiz for Kotlin tutorials.

4-5 correct: You’re pretty solid in your Kotlin trivia, but you still might need to pay a little more attention to the details.

6-7 correct: Nice! You really know your stuff!

8 correct: You are a Kotlin master.

 

Programming Pub Quiz

Have you tried our other pub quizzes? Test your knowledge of other programming languages!

asap

Author

Aswin Shrestha

Aswin is an entrepreneur and co-founder of Programiz.com, a programming site for beginners. He has worked on Enterprise level applications for a multiple of years. He also has vast experiences in the field of 3D Game Development and Web simulation using Three.js. Currently, he heads the technical team at Programiz. Apart from work, you can find him enjoying the delicacies around the world or playing open world games at home.


Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of