InterviewSolution
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. |
Difference in classes and structures in swift? |
| Answer» | |
| 2. |
What is differences in swift 1.x, 2.x, 3.x, 4.x? |
| Answer» | |
| 3. |
Why is inheritance not desirable in Swift? |
|
Answer» 3 reasons INHERITANCE is not GOOD:
|
|
| 4. |
What are JSONEncoder and JSONDecoder? |
|
Answer» Encodable PROTOCOLS take instances of our objects and turn them into data. That data can be stored it to the FILES or sent to the server. |
|
| 5. |
What is tuple? |
|
Answer» It is a group of VALUES represented as one value, which can be used to RETURN multiple values from a single FUNCTION call. |
|
| 6. |
What will you do if your App is prone to crashing? |
|
Answer» First of all, we will DETERMINE the IOS version of the device. Next, we need to collect enough information to reproduce the issue and if possible, acquire the device logs. The last step is to create a unit test and START DEBUGGING once we understand the nature of the issue. |
|
| 7. |
What are Adapter and Memento Patterns? |
|
Answer» ADAPTER pattern allows the classes with INCOMPATIBLE interfaces to work together. An adapter pattern WRAPS itself around the OBJECT to show a standard interface for interacting with that object. |
|
| 8. |
How many Access Levels are present in Swift? |
|
Answer» Swift has five access levels: OPEN access, PUBLIC access, internal access, file-private access, and private access. Open access is the highest access LEVEL and private access is the lowest access level. Almost all ENTITIES, except a few, have default internal access levels. |
|
| 9. |
What is a guard statement? |
|
Answer» These are control flow statements that can be a great ADDITION if you are doing DEFENSIVE style programming. These statements EVALUATE a boolean CONDITION and proceed with the execution only if the evaluation is real. Such statements always have an else clause. |
|
| 10. |
What are the characteristics of Switch? |
Answer»
|
|
| 11. |
What are lazy stored properties, and how are they useful? |
|
Answer» Any property whose initial values are not CALCULATED until the first time it is used is called a lazy stored property. Such PROPERTIES can be DECLARED by writing the lazy modifier. These properties are USEFUL when the initial VALUE of a property is dependent on external factors whose values are unknown. |
|
| 12. |
How will you define base class? |
|
Answer» The classes in SWIFT are not INHERITED from the base class. If you DEFINE any class WITHOUT specifying its SUPERCLASS, it automatically becomes the base class. |
|
| 13. |
What are Floating point numbers? How many types of floating number are there? |
|
Answer» Floating point numbers have a fractional component and they represent a greater RANGE of VALUES than integer types. There are TWO KINDS of floating point numbers – Double and Float. |
|
| 14. |
How can you add Table View? |
|
Answer» Open the storyboard file in Xcode and drag in a “Table View” object from the LIBRARY. POSITION it full screen and make sure the EDGES line up. Now, adjust the height by dragging the edge and CREATING space at the top. Try running the APP in the simulator and you shall see an empty table view. |
|
| 15. |
What do you mean by Initialization? |
|
Answer» It is the process of creating an instance of class, ENUMERATION or structure. It INVOLVES setting an initial value for the existing property and performing initialization before the new instance is available for USE. The initialization process can be done by DEFINING INITIALIZERS. |
|
| 16. |
How can you write multiple line comment? |
|
Answer» The MULTILINE comment enables the programmer to comment out large BLOCKS of code easily. |
|
| 17. |
Can you make a property optional? |
|
Answer» You can MAKE a property optional by declaring a question mark “?” in the CODE. If a property does not hold any value, then this symbol “?” can HELP in avoiding RUNTIME errors. |
|
| 18. |
What collection types are available in Swift? |
|
Answer» THREE COLLECTION types are available - ARRAYS, Sets and Dictionaries. These are used to store different collections of VALUES. These three collection types are mutable and are clear about the types of keys and values associated with them. |
|
| 19. |
What are functions different from methods? |
|
Answer» Functions
|
|
| 20. |
Is "Swift" a good programming language? Explain |
|
Answer» Yes, It is a very powerful, intuitive open SOURCE programming language developed by Apple for iOS, MACOS, watchOS, tv OS, and LINUX etc. |
|
| 21. |
What is the latest version of Swfit Programming? |
|
Answer» SWIFT 5.0 |
|
| 22. |
What is Swift Programming? |
|
Answer» Swift is the latest, OPEN source programming language from APPLE, which is very easy to learn. The language is available for developing OS X, iOS, and watchOS APPS. It ALLOWS developers to prototype and write apps faster and with fewer BUGS than ever before. |
|
| 23. |
How should errors be handled in Swift? |
|
Answer» The WAY to handle errors in Swift is DIFFERENT from Objective-C. In Swift, you can declare that a function has thrown an error. A function that calls this METHOD MUST do it from a try block. It is the caller's responsibility to handle the error. This process is QUITE similar to how we handle errors in Java. |
|
| 24. |
What is optional chaining? |
|
Answer» It is a process of QUERYING and calling various PROPERTIES. You can chain MULTIPLE queries together, but if any link is NIL, the entire chain will fail. |
|
| 25. |
How will you connect Ui? |
|
Answer» UI in Swift are CONNECTED similar to the WAY we do in Objective-C. Binding PROCESS is the same, only core LEVEL has changed. You can select button/label on xib file and BIND as is it. |
|
| 26. |
How is Swift different from Objective-C? |
|
Answer» Swift -
|
|
| 27. |
What are the advantages of Using Swift for iOS Development? |
|
Answer» It is fast, safe, modern, and enables a level of interactivity in development. Swift PROGRAMMING contains a number of features such as closures, GENERICS, and type inference that make it much easier to use.
When you are TRYING to perform extra clean-up of your classes, you can define a block called deinit. |
|