iOS Interview Questions for Freshers Candidates


iOS Interview Questions for Freshers Candidates

Que:1 What is iOS

Ans : iOS stands for "iPhone Operating System." It is the operating system for Apple devices, and it is considered the second most popular mobile operating system globally after Android. This operating system powers many of Apple's products including the iPhone, iPad, and iPod. vgvhvhy

 

Que:2 What is Swift and what is Objective-C?

Objective-C is the primary programming language you use to write software for OS X and iOS. It’s a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime. Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods. It also adds language-level support for object graph management and object literals while providing dynamic typing and binding, deferring many responsibilities until runtime.

Swift is a new programming language for iOS, OS X, watchOS, and tvOS apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift feels familiar to Objective-C developers and is friendly to new programmers.

 

Que:3  When would you say that an app is not in a running state?

An app is said to be in ‘not running’ state in the following cases:

– When it is not launched.

– When it gets terminated by the system during running.

 

Que:4. When is an app said to be in active state? 

An app is said to be in active state when it is running in the foreground and is receiving events.

  

Que:5 Which are the app’s state transitions when it is launched?

An app is said to be in not running state before its launch.

After briefly transitioning through the inactive state, it moves to the active or background state when it is launched.

 

Que:6 What are Cocoa and Cocoa Touch?

Cocoa

Cocoa Touch

1. Application development environments for OS X

1. Application development environments for iOS

2. Includes the Foundation and AppKit frameworks

2. Includes Foundation and UIKit frameworks

3. Used to refer any class/object which is based on the Objective-C runtime & inherits from the root class

3. Used to refer the application development using any programmatic interface

 

Que:7 Explain the different types of iOS Application States.

The different iOS application states are:

Not running state: when the app has not been launched or was running but was terminated by the system.

Inactive state: when the app is running in the foreground but is currently not receiving events. An app stays in this state briefly as it transitions to a different state. The only time it stays inactive is when the user locks the screen or the system prompts the user to respond to some event such as a phone call or SMS message.

Active state: when the app is running in the foreground and is receiving events. This is the normal mode for foreground apps.

Background state: when the app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time can remain in this state for some time. Also, an app being launched directly into the background enters this state instead of the inactive state.

Suspended state: A suspended app remains in memory but does not execute any code. When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

Que:8 Features of the iOS Platform

iOS has become popular. Here are a few of its most notable features: 

The iPhone offers multitasking capabilities. On an iOS device, you can easily switch between apps using the multitasking feature or a multi-finger gesture.

iOS helps you easily integrate social network interactions with your app by displaying an activity stream and sharing content.

Apple's iCloud service allows users to store data on the Internet. It offers a high level of encryption and a backup option to ensure the user does not lose data.

Apple's in-app purchases are available on all platforms, offering users additional services and materials including digital items (iOS, iPad, macOS), subscriptions, and premium content.

You can see all of your app alerts in the Notification Center on iOS. However, the notification settings can be modified.

iOS is a closed system. The source code of Apple's apps isn't available for developers, and iPhone and iPad owners can't modify the code on their devices. This makes iOS-powered devices harder to hack.

 

Que:9 Which is the framework that is used to construct an application’s user interface for iOS?

UIKit framework is used to develop the application’s user interface for iOS. It provides event handling, drawing model, windows, views, and controls specifically designed for a touch screen interface.

 

Que:10 Explain the Architecture of iOS.

iOS operates in a Layered structure. iOS Architecture is comprised of four layers, each of which offers a programming framework for creating applications that operate on top of the hardware. Communication will be enhanced by the layers between the Application Layer and the Hardware Layer. A lower-level layer provides the services that all applications require, while an upper-level layer (or high-level layer) provides graphics and interface-related services.

 

Que:11 Outline the class hierarchy for a UIButton until NSObject.

UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder, UIResponder inherits from the root class NSObject.

 

Que:12 What are layer objects?

Layer objects are data objects which represent visual content and are used by views to render their content. Custom layer objects can also be added to the interface to implement complex animations and other types of sophisticated visual effects.

Que:13 Differentiate between the ‘assign’ and ‘retain’ keywords.

Retain -specifies that retain should be invoked on the object upon assignment. It takes ownership of an object.

Assign – specifies that the setter uses simple assignment. It is used on attributes of scalar type like float, int.

Que14. Which programming languages are used for iOS development?

iOS development is done using the following programming languages: 

  • HTML5
  • .NET
  • C
  • C++
  • Swift
  • Javascript
  • Objective-C.

 

Que: 14. What is the difference between let and var in Swift?

The difference between let and var in Swift is that let creates a constant whose value cannot be changed once set; var defines a variable whose value can be modified. Immutable constants via let offer predictability, performance optimization, and improved thread safety in concurrent programming.

 

Que: 15. What are optionals in Swift, and how do you unwrap them safely?

Optionals in Swift represent a variable that can hold either a value or nil. Swift offers technique called optional binding to safely unwrap optionals, using if let and guard let, and optional chaining with ?. The guard let statement allows early exits from a function if the value is nil. Avoid force unwrapping with ! unless one is certain the value exists, as this can lead to runtime crashes.

 

Que: 16. What is type inference in Swift?

Type inference in Swift means the compiler deduces the type of a variable or constant at compile time, based on the initial value assigned. This makes code concise without sacrificing clarity or type safety.

 

Que: 17. What is the value types and reference types in Swift?

Swift has both value types and reference types. Structs and enums are value types; their data is copied when passed around. Classes are reference types; they reference the same memory location when passed or assigned. Understanding the distinction is crucial for predictable behavior, especially in multi-threaded environments.

 

Que: 18. How does memory management work in Swift?

Swift uses Automatic Reference Counting (ARC) for memory management. ARC tracks and manages the memory used by instances of classes, ensuring that memory is deallocated when it's no longer in use.

 

Que: 19. How do you create custom UI components in iOS?

To create custom UI components in iOS, developers subclass UIView or UIControl and override methods to provide custom drawing and behavior. Components should be modular, reusable, and adhere to the principles of encapsulation.

Que: 20. Can you explain the delegate pattern in iOS and provide an example?

The delegate pattern in iOS allows one object to delegate responsibilities to another. The delegate pattern is used for callback mechanisms. For instance, a UITableView uses a delegate to notify when a row is selected, providing modularity and a clean separation of concerns.