Latest Objective C Interview Questions
1) Explain what objective-C program basically consists of?
Objective-C program basically consists of
Preprocessor commands
Interface
Implementation
Method
Variables
Statements & Expressions
Comments
2) Explain 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) Explain 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.
Ad hoc protocols known as informal protocol
Compiler protocols known as a formal protocol
4) Explain 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) Explain 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.
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) Explain 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) Explain 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) Explain what are the characteristics of the category?
Characteristics of category includes
Even if you don’t have the original source code for implementation, a category can be declared for any class
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
At runtime, there is no variation between a method appended by a category and one that is implemented by the original class
14) Explain 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) Explain 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) Explain 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) Explain 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) Explain 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) Explain 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) Explain 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.