Swift Interview Questions | Eklavya Online

Swift Interview Questions

What is floating point number in Swift? What are the different floating point numbers in Swift?

Numbers with decimal values or fractional components are called floating numbers. For example: 1.34 is a floating point number. Floating point types can represent a wider range of values than integer types. There are two signed floating point number: Double: It represents a 64 bit floating point number. It is used when floating point values …

What is floating point number in Swift? What are the different floating point numbers in Swift? Read More »

How can you write a comment in Swift?

In Swift programming language, single-line comments are started with double slashes (//). For example: // This is a single line comment. Multi-line comment: Multiline comments are started with a forward-slash followed by an asterisk (/*) and end with an asterisk followed by a forward-slash (*/). For example: /* this is multi Line comment*/

What is lazy stored procedure in Swift and when is it used?

Lazy stored properties are used for a property whose initial values are not calculated until the first time it is used. A lazy stored property can be declared by writing the lazy modifier before its declaration. Lazy properties are useful when the initial value for a property is reliant on outside factors whose values are …

What is lazy stored procedure in Swift and when is it used? Read More »

What is Swift? How is it different from Objective-C?

Swift and Objective-C both are used in iOS development but both are significantly different in terms of efficiency and usage. Swift is an open-source programming language developed by Apple platform and expanded to build on Linus while Objective- C is not an open-source programming language and is limited to Apple. Swift syntax is easy, clear …

What is Swift? How is it different from Objective-C? Read More »

What is the usage of switch statement in Swift language?

Switch statement are used as a substitute for the long if-else-if statements. Switch statement supports any type of data, synchronizes them and also checks for equality. Break is not required in switch statement because there is no fall through in switch statement. Switch statement must have covered all possible values for your variable.

What is the meaning of question mark “?” in Swift?

In Swift, question mark “?” is used in property declaration. It tells the compiler that this property is optional. The property may hold a value or not. It avoids runtime errors when accessing that property by using ?. This is useful in optional chaining and a variant of this example is in conditional clauses. For …

What is the meaning of question mark “?” in Swift? Read More »