300+ TOP Objective C Interview Questions and Answers

Objective C Interview Questions for freshers experienced :-

1. What is Objective C?

The Objective-C language is a simple computer language designed to enable sophisticated object-oriented programming. Objective-C is defined as a small but powerful set of extensions to the standard ANSI C language. Its additions to C are mostly based on Smalltalk, one of the first object-oriented programming languages. Objective-C is designed to give C full object-oriented programming capabilities, and to do so in a simple and straightforward way.

2. What is OOP?

OOP means Object Oriented Programming; it is a type of programming technique that helps to manage a set of objects in a system. With the help of various programming languages, this method helps to develop several computer programs and applications.

3. What is the protocol in Objective C?

In Objetive-C, a protocol is a language feature, that provides multiple inheritances in a single inheritance language. Objective C supports two types of protocol.

  1.  Ad hoc protocols known as informal protocol
  2. Compiler protocols known as a formal protocol

4. What is the difference between polymorphism and abstraction?

Abstraction in OOP is the process of reducing the unwanted data and maintaining only the relevant data for the users while polymorphism enables an object to execute their functions in two or more forms.

5. What is parsing and mention which class can we use for passing of XML in iphone?

Parsing is the process referred to access the data in the XML element. We can use class “NSXML” parser for passing XML in iphone.

file-322084488

6. Mention which class are used to establish a connection between applications to the web server?

The class used to establish connection between applications to web server are

  • NSURL
  • NSURL REQUEST
  • NSURL CONNECTION

7. What is an accessor methods?

Accessor methods are methods belonging to a class that enables you to get and set the values of instance valuable contained within the class.

8. What is #import?

#import is a C pre-processor construct to avoid multiple inclusions of the same file.

9. Mention what is the class of a constant string?

It’s and NXConstantString. NXConstantString *myString = @ “my string”;

10. List out the methods used in NSURL connection?

Methods used in NSURL connection are

  • Connection did receive response
  • Connection did receive data
  • Connection fail with error
  • Connection did finish loading

11. Explain class definition in Objective-C?

A class definition begins with the keyword @interface followed by the interface (class. name, and the class body, closed by a pair of curly braces. In Objective-C, all classed are retrieved from the base class called NSObject. It gives basic methods like memory allocation and initialization.

12. Mention what is the use of category in Objective-C?

The use of category in Objective-C is to extend an existing class by appending behavior that is useful only in certain situations. In order to add such extension to existing classes, objective –C provides extensions and categories. The syntax used to define a category is @interface keyword.

13. What are the characteristics of the category?

Characteristics of category includes

  1. Even if you don’t have the original source code for implementation, a category can be declared for any class
  2. Any methods that you define in a category will be available to all instances of the original class as well as any sub-classes for the original class
  3. At runtime, there is no variation between a method appended by a category and one that is implemented by the original class

14. What is single inheritance in Objective-C?

Objective-c subclass can only be obtained from a single direct parent class this concept is known as “single inheritance” .

15. What is polymorphism in Objective-C?

Polymorphism in Objective-C is referred to a capability of base class pointer to call the function.

16. Explain when to use NSArray and NSMutableArray?

NSArray: You will use an NS array when data in the array don’t change. For example, the company name you will put in NS Array so that no one can manipulate it.
NSMutableArray: This array will be used in an array, when data in an array will change. For instance, if you are passing an array to function and that function will append some elements in that array then you will choose NSMutable Array.

17. What is synthesized in Objective-C?

Once you have declared the property in objective-C, you have to tell the compiler instantly by using synthesize directive. This will tell the compiler to generate a getter&setter message.

18. Explain how string is represented in Objective-C?

In Objective-C, the string is represented by using NSS string and its sub-class NSMutableString provides several ways for creating string objects.

19. What is data encapsulation in Objective-C?

In Objective-C, data encapsulation is referred to the mechanism of connecting the data and the functions that use them.

20. Explain how to call the function in Objective-C?

To call the function in Objective-C, you have to do Account -> Object Name -> Display account information -> Method name

21. What are objective- C blocks?

In Objective-C class, there is an object that combines data with related behavior. It enables you to form distinct segments of code that can be passed around to functions or methods as if they were values. Objective-C blocks can be added to collections like NSDictionary or NSArray.

22. What is the main difference between the function calls and messages?

The main difference between function call and message is that a function and its arguments are linked together in the compiled code, but a message and a receiving object are not linked until the program is executing and the message is sent.

23. Explain how messaging works in Objective-C?

Messaging are not bound to method implementation until runtime in Objective-C. The compiler transforms a message expression, into a call on a messaging function, objc_msgSend(). This function connects the receiver and the name of the method mentioned in the message.

24. Explain how the class “IMPLEMENTATION” is represented in Objective-C?

In Objective-C the class “ IMPLEMENTATION” is represented with @implementation directive and ends with @end.

25. What is dot notation?

Dot notation involves assessing an instance variable by determining a class “instance” followed by a “dot” followed in turn by the name of instance variable or property to be accessed.

26. Mention whether NS object is a parent class or derived class?

NS object is the parent class and consists of a number of instance variables and instance methods.

27. What objective-C program basically consists of?

Objective-C program basically consists of

  • Preprocessor commands
  • Interface
  • Implementation
  • Method
  • Variables
  • Statements & Expressions
  • Comments

OBJECTIVE C Questions and Answers Pdf Download

  • identify basic OO concepts and the keywords Objective-C uses (interface, implementation, property, protocol, etc)
  • what is a designated initializer, what is the pattern for the initializers and why ( if (self = [super …] ) )
  • basic memory management topics, like ownership retain/release/autorelease
  • what happens if you add your just created object to a mutable array, and you release your object
  • what happens if the array is released
  • what happens if you remove the object from the array, and you try to use it
  • trick: garbage collection on iPhone
  • autorelease pool usage
  • property declarations ( assign, nonatomic, readonly, retain, copy )
  • trick: ask about the nonexistent atomic keyword, what does atomic mean
  • ask on how to correctly implement a retaining setter property
  • ask about the circular reference problem and delegates being usually saved with assign rather then retain
  • what is the difference between the dot notation and using the square brackets
  • what happens when we invoke a method on a nil pointer
  • difference between nil and Nil
  • what is KVO and related theory + methods to use when observing
  • does KVO work with ivars too?
  • protocols – maybe: main difference between c#/java interface and protocols
  • what to do in a situation when a class doesn’t implement a method from a protocol
  • what about multiple class inheritance
  • what is fast enumeration
  • class methods vs instance methods
  • visibility of methods
  • what is an actual class in Objective-c (struct)
  • ask about the isa member
  • ask about isKindOfClass isMemberOfClass
  • root classes: NSObject, NSProxy
  • how does proxy-ing work
  • how to fake multiple class inheritance
  • id type
  • what happens during compilation if we invoke a method on an variable with the type id
  • what happens runtime if the method exists
  • what happens if the methods doesn’t exist
  • pro and cons of using the type id
  • what happens here(compile + runtime): NSString *s = [NSNumber numberWithInt:3]; int i = [s intValue];
  • what are class categories and the () category
  • what is an informal protocol
  • what is a delegate, how to create one, and use one
  • what is a selector, how to do a perform selector
  • how to delay executing a selector
  • what to do when the selector has more paramters (NSInvocation>
  • how to start a selector on a background thread
  • how to start a thread
  • what is the first thing to do on a thread (autorelease pool)
  • what is a runloop, and one very common place where it is used (timers, nsurlconnection)
  • how to download something from the internet
  • what is the difference between a synchronous and an asynchronous request
  • small task: explain how to download an image from the internet, and show this in an image view – all this after a button is tapped on the view
  • what are notifications, how to use them
  • what is a memory warning, how do we respond to it
  • when to use retainCount (never, and why)
  • why shouldn’t we invoke instance methods in an initializer and the dealloc
  • NSCoding, archiving
  • NSCopying, why can’t we simply use our own objects as key in a dictionary, what to do to solve the problem ( and the difference between a shallow and a deep copy)

UIKit Related Questions

  • what is a view, and a window
  • difference between a view’s bounds and frame
  • what is the resolution of the current available devices, difference between points and pixels (starting with iOS4)
  • what is the responder chain, becomeFirstResponder
  • what do IBOutlet and IBAction mean, what are they preprocessed to
  • how do tableviews function
  • what about multithreading and UIKit
  • what to do when the keyboard appears and hides some parts of the UI that are important
  • why should we release the outlets in viewDidUnload
  • what is awakeFromNib, what is the difference between a nib and a xib

CoreData Questions

  1. what is a context
  2. what about multi threading and core data usage
  3. what is an NSManagedObjectId – can we save it for later if the application was stopped
  4. what types of stores does core data support
  5. what is lazy loading, how does this relate to core data, situations when this can be handy
  6. how to ready only a few attributes of an entity
  7. what is an fetch result controller
  8. how to synchronize contexts
  9. how could one simulate an NSManagedObject (i’m thinking of the fact that all the properties are dynamic and not synthesized)

Leave a Reply

Your email address will not be published. Required fields are marked *