This page contains the list of most asked swift interview questions and answers with examples. By using these swift question answer, you can improve your knowledge of swift programming language.
Q1: What is the use of double question marks?
The double question marks assign a default value for a variable in swift programming.
Q2: What is type aliasing in Swift programming?
Swift programming allows you to alias a type which is inherited from C/C++ programming languagge.
Q3: How to write a program to add two numbers?
Below program will allow you to add tow numbers:
var x = 15
var y = 5
var z = 0;
z = x + y;
Q4: How can you write a multiple line comment Swift?
You can wirte the multiple line comment between the symbols (/*) at the start and (*/) at the end of your code.
Q5: What are the control transfer statements in swift?
Below are the list of control transfer statement used in swift programming:
Q6: What is the significance of “?” in swift?
The significance of question mark makes a property optional if declared in case the property does not hold any value in swift programming. It is used to avoid runtime errors.
Q7: How to remove an item from the dictionary?
Use the below code to remove an item from the dictionary:
//Create a Dictionary with two elements
var myDictionary = ["first_name": "Sergey", "last_name": "Kargopolov"]
// print to preview
//Remove an item
// print dictionary to preview
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.