Câu hỏi phỏng vấn Kotlin
Câu hỏi

What is a difference between a class and object in Kotlin?

Câu trả lời

Here is an explanation of the difference between a class and an object in Kotlin:

Classes

  • A class is a blueprint or template for creating objects
  • It defines the properties (data) and functions (behavior) that objects of that class will have
  • Classes are defined using the class keyword followed by the class name
  • You can create multiple objects from a single class
  • Classes are not instantiated until an object is created from them

Objects

  • An object is a specific instance of a class
  • It contains the actual data and can perform the behaviors defined in the class
  • Objects are created from classes using the new keyword or a constructor
  • Each object has its own copy of the properties defined in the class
  • Objects can access and modify their own properties and call their own functions

The key differences are:

  • A class is a template, while an object is a...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

What is the Kotlin double-bang !! operator?

middle

What is the idiomatic way to deal with null able values, referencing or converting them?

middle

May you use IntArray and an Array is in Kotlin interchangeably?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào