iOS

Swift Basics

Variables & constants, types, optionals, closures, control flow, error handling

25 pertanyaan wawancaraยท
Junior
1

What is the difference between 'let' and 'var' in Swift?

Jawaban

let declares an immutable constant while var declares a mutable variable. A constant cannot be changed after declaration, but a variable can change value. Use let by default for safety and code clarity.

2

Which data type is used to represent true or false in Swift?

Jawaban

The Bool type is used for boolean values true and false. It is a fundamental type in Swift used in conditionals to control execution flow. Other types serve different purposes: Int for integers, String for text, Boolean does not exist in Swift.

3

What is type inference in Swift?

Jawaban

Type inference allows Swift to automatically deduce a variable's type from its initial value. For example, if you assign 42, Swift infers Int. If you assign text, Swift infers String. This makes code concise without losing type safety. You can annotate explicitly if needed.

4

What is an optional in Swift?

5

How do you safely unwrap an optional using 'if let'?

+22 pertanyaan wawancara

Kuasai iOS untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis