kotlin面试_Kotlin面试问题

kotlin面试

Kotlin is the latest JVM programming language from the JetBrains. Google has made it the official language for Android Development along with Java. Developers say it addresses the issues faced in Java programming. I have written a lot of Kotlin tutorials and here I am providing important kotlin interview questions.

Kotlin是JetBrains中最新的JVM编程语言。 Google使其与Java一起成为Android开发的官方语言。 开发人员说,它解决了Java编程面临的问题。 我写了很多Kotlin教程,在这里我提供了重要的Kotlin面试问题。

Kotlin面试问题 (Kotlin Interview Questions)

Here I am providing Kotlin Interview Questions and Answers that will help you in your Kotlin Interviews. These Kotlin interview questions are good for beginners as well as experienced programmers. There are coding questions too to brush up your coding skills.

在这里,我提供了Kotlin面试问答,可以帮助您进行Kotlin面试。 这些Kotlin面试问题对初学者和经验丰富的程序员都非常有用。 还有一些编码问题可以提高您的编码技能。

  1. Kotlin的目标平台是什么? Kotlin-Java如何互操作? (What’s the Target Platform of Kotlin? How is Kotlin-Java interoperability possible?)

    Java Virtual Machine(JVM) is the Target Platform of Kotlin. Kotlin is 100% interoperable with Java since both, on compilation produce bytecode. Hence Kotlin code can be called from Java and vice-versa.

    Java虚拟机(JVM)是​​Kotlin的目标平台。 Kotlin可与Java 100%互操作,因为两者在编译时都会产生字节码。 因此,可以从Java调用Kotlin代码,反之亦然。

  2. 您如何在Kotlin中声明变量? 声明与Java声明有何不同? (How do you declare variables in Kotlin? How does the declaration differ from the Java counterpart?)

    There are two major differences between Java and Kotlin variable declaration:

    • The type of declaration
      In Java the declaration look like this:
      String s = "Java String";
      int x = 10;

      In Kotlin the declaration looks like:

      In Kotlin, the declaration begins with a val and a var followed by the optional type. Kotlin can automatically detect the type using type inference.

    • Default value
      The following is possible in Java:
      String s:

      The following variable declaration in Kotlin is not valid.

    Java和Kotlin变量声明之间有两个主要区别:

    • 申报类型
      在Java中,声明如下所示:
      String s = "Java String";
      int x = 10;

      在Kotlin中,声明如下所示:

      在Kotlin中,声明以valvar开头,后跟可选类型。 Kotlin可以使用类型推断自动检测类型。

    • 默认值
      Java中可能有以下内容:
      String s:

      Kotlin中的以下变量声明无效。

  3. val和var声明有什么区别? 如何将字符串转换为Int? (What’s the difference between val and var declaration? How to convert a String to an Int?)

    val variables cannot be changed. They’re like final modifiers in Java. A var can be reassigned. The reassigned value must be of the same data type.

    fun main(args: Array<String>) {
        val s: String = "Hi"
        var x = 5
        x = "6".toInt()
    }

    We use the toInt() method to convert the String to an Int.

    val变量不能更改。 它们就像Java中的最终修饰符。 可以重新分配var 。 重新分配的值必须具有相同的数据类型。

    我们使用toInt()方法将String转换为Int。

  4. 什么是Kotlin中的Null安全性和Nullable类型? 猫王算子是什么? (What’s Null Safety and Nullable Types in Kotlin? What is the Elvis Operator?)

    Kotlin puts a lot of weight behi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值