This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What Is Swift Programming Language? |
|
Answer» Swift is an INNOVATIVE NEW programming language for Cocoa and Cocoa TOUCH. Writing code is interactive and fun, the syntax is concise YET expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C. Swift is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C. |
|
| 2. |
How To Define Variables In Swift Language? |
|
Answer» Constants and variables must be DECLARED before they are used. You DECLARE constants with the LET KEYWORD and variables with the var keyword. let maximumNumberOfLoginAttempts = 10 var currentLoginAttempt = 0 Constants and variables must be declared before they are used. You declare constants with the let keyword and variables with the var keyword. let maximumNumberOfLoginAttempts = 10 var currentLoginAttempt = 0 |
|
| 3. |
How To Define Ksomeconstant As An Integer? |
|
Answer» In this case kSomeConstant is implicitly defined as an INTEGER. If you WANT to be more specific you can specify which type it is LIKE so: let kSomeConstant: Int = 40 In this case kSomeConstant is implicitly defined as an integer. If you want to be more specific you can specify which type it is like so: let kSomeConstant: Int = 40 |
|
| 4. |
What Is Best Way To Add A Table View? |
|
Answer» Open storyboard file in Xcode and LETS drag in a “Table VIEW” object from the Object Library (don’t use a table view controller.) Position this full screen in your app window and make sure it lines up with the EDGES. Then resize the height by dragging down the top edge and giving a LITTLE BIT of space (this gives room for the status bar at the top of the phone.) If you run the app at this point, you should see an empty table view in the simulator. Open storyboard file in Xcode and lets drag in a “Table View” object from the Object Library (don’t use a table view controller.) Position this full screen in your app window and make sure it lines up with the edges. Then resize the height by dragging down the top edge and giving a little bit of space (this gives room for the status bar at the top of the phone.) If you run the app at this point, you should see an empty table view in the simulator. |
|
| 5. |
How To Connect Ui In Swift Language? |
|
Answer» Same as like c-objective. There is no CHANGE in binding PROCESS only core LEVEL has been changed. You can CHOOSE button/label on xib file and binding as is it. Same as like c-objective. There is no change in binding process only core level has been changed. You can choose button/label on xib file and binding as is it. |
|
| 6. |
What's New Features In Swift 4.0? |
Answer»
|
|
| 7. |
What Is Initialization ? |
|
Answer» Initialization is the process of preparing an instance of a class, structure, or ENUMERATION for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization that is required before the new instance is ready for use. You implement this initialization process by defining initializers, which are like special methods that can be called to CREATE a new instance of a particular type. Unlike Objective-C initializers, Swift initializers do not return a value. Their primary ROLE is to ensure that new instances of a type are correctly initialized before they are used for the first time. Initializers Initializers are called to create a new instance of a particular type. In its simplest form, an initializer is like an instance method with no parameters, written using the INIT keyword: init() { // perform some initialization here } Initialization is the process of preparing an instance of a class, structure, or enumeration for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization that is required before the new instance is ready for use. You implement this initialization process by defining initializers, which are like special methods that can be called to create a new instance of a particular type. Unlike Objective-C initializers, Swift initializers do not return a value. Their primary role is to ensure that new instances of a type are correctly initialized before they are used for the first time. Initializers Initializers are called to create a new instance of a particular type. In its simplest form, an initializer is like an instance method with no parameters, written using the init keyword: init() { // perform some initialization here } |
|
| 8. |
Is Swift Object Oriented Programming? |
|
Answer» YES! SWIFT is an Object-Oriented PROGRAMMING LANGUAGE. Yes! Swift is an Object-Oriented Programming language. |
|
| 9. |
What Are The Advantages Of Swift? |
| Answer» | |
| 10. |
What Is The Difference Between Swift And Objective-c Language? |
|
Answer» Swift Programming-
Objective-C Programming-
Swift Programming- Objective-C Programming- |
|
| 11. |
What Is The Significance Of “?” In Swift? |
|
Answer» The question mark (?) is USED during the declaration of a property. If the property does not HOLD a value, the question mark (?) helps to avoiding application errors. Example LOOKS like - class Employee { VAR certificate : [Certificates]? } LET employee = Employee(); Example 2 - let middleName : String? = nil let lastName : String = "Singh" let name : String = middleName ?? lastName The question mark (?) is used during the declaration of a property. If the property does not hold a value, the question mark (?) helps to avoiding application errors. Example looks like - class Employee { var certificate : [Certificates]? } let employee = Employee(); Example 2 - let middleName : String? = nil let lastName : String = "Singh" let name : String = middleName ?? lastName |
|
| 12. |
What Is A Deinitializer In Swift? |
|
Answer» If you WANT to PERFORM an ADDITIONAL clean-up of your classes, it is POSSIBLE to define a block called deinit. Syntax - deinit { //Your cleanup statement here. } If you want to perform an additional clean-up of your classes, it is possible to define a block called deinit. Syntax - deinit { //Your cleanup statement here. } |
|
| 13. |
How Multiple Line Comment Can Be Written In Swift? |
|
Answer» The Nested multiline comments ENABLE you to comment out large blocks of code QUICKLY and easily. Use an opening (/*: ) and CLOSING ( */) comment and it LOOKS like - /*: The above forward slash (/) and an asterisk (*) then a COLON (:) is opening comment - (/*:) … The below an asterisk (*) and forward slash is closing comment – (*)) */ The Nested multiline comments enable you to comment out large blocks of code quickly and easily. Use an opening (/*: ) and closing ( */) comment and it looks like - /*: The above forward slash (/) and an asterisk (*) then a colon (:) is opening comment - (/*:) … The below an asterisk (*) and forward slash is closing comment – (*)) */ |
|
| 14. |
How Can You Make A Property Optional In Swift? |
|
Answer» DECLARING a QUESTION mark “?” in the code can make a property optional. If a property doesn’t hold a value, then this symbol “?” HELPS in AVOIDING the runtime errors. Declaring a question mark “?” in the code can make a property optional. If a property doesn’t hold a value, then this symbol “?” helps in avoiding the runtime errors. |
|
| 15. |
What Do You Do When You Realize That Your App Is Prone To Crashing? |
Answer»
|
|
| 16. |
Can You Explain Completion Handler? |
| Answer» | |
| 17. |
Distinguish Between @synthesize And @dynamic In Objective –c? |
|
Answer» @synthesize – It generates the GETTER and setter methods for the property. @DYNAMIC – It notifies the COMPILER that the getter and setter are implemented at some other PLACE. @synthesize – It generates the getter and setter methods for the property. @dynamic – It notifies the compiler that the getter and setter are implemented at some other place. |
|
| 18. |
Explain Why A Compile Time Error Occurs. How Can You Fix It? |
|
Answer» STRUCTURES are value types. By DEFAULT, the properties of a value type cannot be modified from WITHIN its instance methods. However, you can optionally allow such modification to OCCUR by declaring the instance methods as ‘mutating’; EX: struct IntStack { var items = [Int]() mutating func add(x: Int) { items.append(x) // All good! } } Structures are value types. By default, the properties of a value type cannot be modified from within its instance methods. However, you can optionally allow such modification to occur by declaring the instance methods as ‘mutating’; EX: struct IntStack { var items = [Int]() mutating func add(x: Int) { items.append(x) // All good! } } |
|
| 19. |
Explain Functions? |
|
Answer» It LETS you group a SERIES all together to perform a SPECIFIC task.A function once CREATED can be over and over in the code, and in case you find a repeating statement in the code, then the function can be the ANSWER to avoid the repetition. It lets you group a series all together to perform a specific task.A function once created can be over and over in the code, and in case you find a repeating statement in the code, then the function can be the answer to avoid the repetition. |
|
| 20. |
Can You Explain Regular Expression And Responder Chain? |
|
Answer» Regular Expression – These are the special string patterns that describe how a SEARCH is PERFORMED through a string. RESPONDER Chain – It is a hierarchy of objects that obtain the opportunity to RESPOND to the EVENTS. Regular Expression – These are the special string patterns that describe how a search is performed through a string. Responder Chain – It is a hierarchy of objects that obtain the opportunity to respond to the events. |
|
| 21. |
What Is Dictionary In Swift? |
|
Answer» It enables you to store the key-value pairs and access the value by providing the key.It is SIMILAR to that of the HASH TABLES in other PROGRAMMING languages. It enables you to store the key-value pairs and access the value by providing the key.It is similar to that of the hash tables in other programming languages. |
|
| 22. |
Explain Some Common Execution States In Ios? |
|
Answer» The states of the common execution can be as FOLLOWS: Not RUNNING – This state means that there is no code that is being executed and the application is COMPLETELY switched off. Inactive – This state means that the application is running in the BACKGROUND and is not receiving any EVENTS. Active – This state means that the applications are running in the background and is receiving the events. Background – This state means that the application is executing the code in the background. Suspended – This state means that the application is in the background and is not executing. The states of the common execution can be as follows: Not running – This state means that there is no code that is being executed and the application is completely switched off. Inactive – This state means that the application is running in the background and is not receiving any events. Active – This state means that the applications are running in the background and is receiving the events. Background – This state means that the application is executing the code in the background. Suspended – This state means that the application is in the background and is not executing. |
|
| 23. |
Explain The Adapter And Memento Pattern? |
|
Answer» Adapter – It lets the classes with incompatible interfaces to work TOGETHER and it WRAPS itself around the object to expose a STANDARD interface to interact with that object. Memento – This pattern in iOS is used as a part of state RESTORATION. That is this externalized state can be restored without violating any encapsulation.This pattern is especially used for the archiving in APPLE. Adapter – It lets the classes with incompatible interfaces to work together and it wraps itself around the object to expose a standard interface to interact with that object. Memento – This pattern in iOS is used as a part of state restoration. That is this externalized state can be restored without violating any encapsulation.This pattern is especially used for the archiving in Apple. |
|
| 24. |
How Can You Define A Base Class In Swift? |
|
Answer» The classes are not inherited DIRECTLY from the base class in the SWIFT programming language.The classes defined by the DEVELOPER WITHOUT SPECIFYING the superclass becomes the base class automatically. The classes are not inherited directly from the base class in the Swift programming language.The classes defined by the developer without specifying the superclass becomes the base class automatically. |
|
| 25. |
What Are The Control Transfer Statements In Swift? |
|
Answer» The control TRANSFER STATEMENTS in swift are:
The control transfer statements in swift are: |
|