×

Top 30 Swift Interview Questions for 2024

1) What is Swift?

It is an innovative programming language developed by Apple Inc. It is used for creating applications for iOS and OS X.

2) What are the features of Swift Programming?

Features of Swift Programming are:
  • It eliminates all the classes of unsafe code
  • Variables are initialized before use
  • Integers are checked for overflow
  • Arrays are checked for overflow
  • Memory management is automatic
  • swift has "switch" function Instead of "If" statement

3) What are the types of collection available in Swift?

There are two types of collections available in Swift are:
  • Array (Array of a single type or an array with multiple types)
  • Dictionary(Similar to a Hash table as in other programming language)

4) List out what are the control transfer statements used in Swift?

Control transfer statements used in Swift are:
  • Break
  • Return
  • Continue
  • Fallthrough

5) How to define Constants and Variables in Swift language?

Before Constants and Variables are used they must be declared. Constants declared with "let" keyword and Variables are declared with "var" keyword.

6) What are the types of access control in Swift language?

There are three types of access control in Swift language are:
  • Public
  • Internal
  • Private

7) What are the characteristics of Switch in Swift?

Characteristics of Switch in Swift are:
  • Switch statement must be exhaustive
  • There is no fallthrough in switch statements
  • Supports any kind of data
  • Supports synchronization and also check for equality

8) What are the types of Integer Literals available in Swift language?

There are four types Integer Literals in Swift are:
    • Decimal
Example: decimal Integer = 17
    • Binary (Begin with 0b)
Example: binary Integer=0b10001
    • Octal (Begin with 0o)
Example: octal Integer = 0o21
    • Hexadecimal (Begin with 0x)
Example: hexadecimal Integer=0x11

9) What are the types of Operators available in Swift language?

Types of Operators in Swift are :
  • Misc Operators
  • Range Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
  • Arithmetic Operators
  • Comparison Operators

10) What is ARC in Swift?

ARC is stands for Automatic reference counting. It is used for Memory Management and provides information about the relationships between our code instances. It is also is used to initialize and deinitialize the system resources.

11) Write a basic program in Swift to print "Swift Expert" for OS X playground?

Example:
import Cocoa  

var myString = "Swift Expert"  

println(myString)
Output:
Swift Expert

12) Write a basic program in Swift to print "iOS Playground" for iOS playground?

Example:
import UIKit  

var myString = "iOS Playground"  

println(myString)
Output:
iOS Playground

13) What are the types of decision making statements available in Swift language?

Types of decision making statements in Swift Language are:
    • if statement:
It consists of a Boolean expression followed by one or more statements.
    • if...else statement
    • if...else if...else Statement
    • nested if statements:
Here we can use one if or else if statement inside another if or else if statement.
  • switch statement:
It is used to test a variable for equality against a list of values.

14) What is Initializers in Swift language?

Initializers: It is used to add new initializers to an existing type by extensions. Here, extensions supports only init() and deinit() is not supported by the extensions.

15) What are the Features of "Objective-C" language?

Features of "Objective-C" language :
  • Variables are declared as NSString and constant as int
  • Here, the code ends with semi-colon
  • Here we need to choose between NSMutableString and NSString for string to be modified
  • addObject() method of NSMutable array is used to append a new item to an array

16) Who is the developer of Swift programming language?

Chris Lattner is the developer of Swift programming language.

17) What is import in Swift?

Import: We can use the import statement to import any Objective-C framework, libraries and APIs directly into your Swift program.

18) What are the types of built-in data types available in Swift?

The types of built-in data types available in Swift are:
  • Int or UInt
  • Float
  • Double
  • Bool
  • String
  • Character
  • Optional

19) What is the syntax to declare the typealias in Swift?

The syntax to declare the typealias is:
typealias newname = type

20) What is the syntax to declare variables in Swift?

The syntax to declare variables in Swift:
var variableName = <initial value>

21) What are the two values of optional in Swift programming language?

The two values of optional are:
  • None
  • Some(T)

22) What is the syntax to declare optional Integer in Swift?

The syntax to declare optional Integer is:
  1. var perhapsInt: Int?

23) What is the syntax to declare Constants in Swift?

The syntax to declare Constants is:
let constantName = <initial value>

24) What is String literal in Swift?

String literal: It is a sequence of characters surrounded by double quotes. It cannot contain an unescaped double quote ("), an unescaped backslash (\), a line feed, or a carriage return.

25) What is the use of fallthrough statement in Swift?

fallthrough statement: This statement is used to simulate the behavior of swift switch to C-style switch.

26) Which literal is used to create an empty string in Swift?

Empty String literal is used to create an empty string in Swift.

27) Which Boolean property is used to check whether a string is empty or not?

isEmpty Boolean property is used to check whether a string is empty or not.

28) What is the use of hasPrefix(prefix: String) function in Swift?

hasPrefix(prefix: String) function: This String function is used to check whether a given parameter string exists as a prefix of the string or not.

29) What is utf8 in Swift?

utf8 is a property of String that is used to return a UTF-8 representation of a string.

30) What is the use of enumerate() function in Swift array?

enumerate() function: This function is used to return the index of an item along with its value.

Related Topics

Top 32 Laravel Interview Questions for 2024

1) What is Laravel? Laravel is an open source PHP framework. It is used to design and develop web applications. It is based on MVC (Model-View-Controller) design pattern. It is created by Taylor...

6 minutes read.

Top 30 Magento Interview Questions for 2024

1) What is Magento? Magento is an open-source content management system. It is used to create e-commerce websites. It is developed by Varien ,Inc, a US private company headquartered in Culver City, California. It...

5 minutes read.

Top 30 Flex Interview Questions for 2024

1) What is Flex? Flex is an open source framework which is used to build applications for mobile, browser and desktop. It provides FLEX SDK consisting of the Flex class library, Flex...

4 minutes read.

Top 29 Phalcon Framework Interview Questions for 2024

1) What is Phalcon? Phalcon is an open source framework based on the MVC (Model-View-Controller) pattern. It is the combination of PHP and C language. It is developed by Andres Gutierrez...

6 minutes read.

Top 31 CakePHP Interview Questions for 2024

1) What is CakePHP? CakePHP is an open-source PHP framework. It is used to develop dynamic web applications. It helps to developers to work in a structured manner. 2) When cakePHP was...

5 minutes read.

Top 14 MathML Interview Questions for 2024

1) What is MathML? MathL stands for Mathematical Markup Language. It is extended form of XML. It is used to describe mathematical and scientific notations. 2) Who is the developer of MathML? World...

3 minutes read.

Top 30 DBMS Interview Questions for 2024

1) What is DBMS? DBMS (Data Base Management System) is a technology for managing data of database i.e. Create, Update, Delete, Alter. 2) What is a Database System? It is defined as collection...

4 minutes read.

Top 28 Scala Interview Questions for 2024

1) What is Scala? Scala is a functional and object-oriented programming language. It is used to develop web application, mobile application, enterprise application, desktop based application etc. Everything in Scala is in object...

4 minutes read.

Top 50 ReactJS Interview Questions for 2024

Top 50 Frequently asked ReactJS Interview Questions Q-1. What is React? Ans-1 React is a front-end JavaScript library which is developed by Facebook in 2011. It follows the component-based approach and allows us to...

15 minutes read.

Top 15 RESTful Web Services Interview Question for 2024

1) What is REST? REST is web standards based architecture and stands for REpresentational State Transfer. It uses HTTP Protocol for data communication. Here, everything is a resource. 2) What are the HTTP methods used...

2 minutes read.

Top 15 Foundation Interview Questions for 2024

1) What is Foundation? Foundation is a front-end framework that is for designing beautiful responsive websites. This framework is compatible with all types of devices and provides you with HTML, CSS...

2 minutes read.

Top 14 Apache Presto Interview Questions for 2024

1) What is Presto? Presto is a distributed SQL query engine. It is an open source software project to develop a database. 2) What are the features of Presto? There are following features...

2 minutes read.

Top 15 CherryPy Interview Questions for 2024

1) What is CherryPy? CherryPy is a web framework used for Python. It provides a friendly interface for Http protocol for Python developer. 2) Why we use CherryPy? CherryPy has following strength: Simplicity: It...

3 minutes read.

Top 31 Dart Programming Interview Questions for 2024

1) What is Dart? Dart is an application programming language. It is used to build web, server and mobile applications. 2) Who is the developer of Dart? Google is the developer of Dart. 3)...

6 minutes read.

Top 30 SQL Interview Questions for 2024

1. What is SQL? Ans. SQL stands for Structured Query Language.  It is a standard computer language for accessing, storing, and manipulating data stored in the relational database. SQL become an International Standard Organization (ISO)...

11 minutes read.

Top 15 Euphoria Interview Questions for 2024

1) What is Euphoria? Euphoria is a programming language. It is open source, powerful and easy to learn. It stands for End-User Programming with Hierarchical Objects for Robust Interpreted Applications 2) Who...

2 minutes read.

Top 15 Cordova Interview Questions for 2024

Top 20 Cordova Interview Questions and Answers for Freshers 1) What is Cordova? Cordova is a mobile application development framework. Cordova allows building mobile application using HTML5, CSS3, and JavaScript. Cordova is...

3 minutes read.

Top 30 Less Interview Questions for 2024

1) What is Less? Less is a dynamic style sheet language that can be compiled in to CSS (Cascading style Sheet). It runs on client side and server side. It is...

4 minutes read.

Top 20 C Programming | Coding Interview Questions for 2024

Most Frequently asked C programming | Coding Interview Questions and answer for Fresher C is a powerful high-level programming language.  It is a fast, portable and available for all platforms. C...

15 minutes read.

Top 15 ExpressJS Interview Questions for 2024

1) What is ExpressJs? Express Js is a framework for node.js which is light-weight and fast. It is used to develop web and mobile applications. 2) What are the features of ExpressJs? Following...

4 minutes read.