Objective C Interview Questions

Objective C Interview Questions

Sharing is caring!

Objective C is a general purpose, object oriented programming language. It is mainly used by Apple for the OS X and iOS operating systems. Here are the top 25 Objective C interview questions and answers.

1. Explain what objective-C program basically consists of ?

It basically consist of

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

2. Define #Import ?

# import is  a preprocessor construct to avoid multiple inclusion of the same file.

3. What is Objective C ?

It is a type of programming language which helps in the process of Object Oriented Programming. ObjectiveC is used by Apple for OS X and iOS operating system.

4. What is a protocol ?

It is a language feature in objective C which provides multiple inheritance in a single inheritance language . There are two types of protocol supported by objective C

  • Ad hoc protocols called informal protocol
  • Compiler protocols called formal protocols

5. List the  methods used in NSURL connection in Objective C ?

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

6. List the methods in  Objective C  for memory management?

Two methods are used for memory management in Objective C

  • MRR- Manual Retain Release
  • ARC- Automatic Reference Counting

7. Write the output of the below code ?

Explanation

var +~0 = 3 + ~0 = 3 + (-1) = 2

Assume string “julies” and “kailas” has stored at

memory address 100 and 500 respectively

For string “julies”: 100 to 106

For string “kailas”: 500 to 506

In this program Cycling is array of character‟s pointer

of size 2. So array Cycling  will keep the memory

address of first character of both strings i.e. content

of array Cycling is:

Cycling[2] = {100,500}

ptr is character pointer which is pointing to the fist

element of array cricket. So, ptr = 100

Now consider on *++ptr

ptr = 100, after ++ptr, ptr = 101

*(++ptr) = *(101) = content of memory address 101.

character is l.

8. Write the output of the below code ?

Explanation

In C Size of any array cannot be constant variable.

9. Write the output of the below code ?

Explanation

Compilation error because the name of the variable is invalid. Variable name should start with alphabet or underscore.

10. Write the output of the below code ?

Explanation

when i++  postfix increment operator is used in  expression, it first assign  its value in the expression  and then  it increments the value of variable by two . So,

i = 3 +3  *2

i=6

i will be incremented by 2

i=6+2=8

objective c interview questions

11. Write the output of the below code ?

Explanation

Break keyword is not a part of if -else statement. It can be used in case of loop or case statements. So the compiler shows the misplaced break error.

12. Write the output of the below code ?

Explanation

The program control will come in each case after the case condition is satisfied.

13. Write a program to print Hello World without using any semicolon ?

14. List the characteristics of Objective C ?

  • The class is defined as @inheritance and @implementation
  • Objects have instance variables
  • Objects and instance variables have scope.
  • Objects are referred as receivers, as it receives message .

15. What is an accessor method ?

It is a method belonging to  a class that enables you to get and set the values of instance valuable contained within the class.

16. Define single inheritance in Objective C ?

In Objective C subclass can only be obtained from a single direct parent class this concept is called “single inheritance”.

17.  Define Polymorphism in Objective C ?

It is referred to a capability of base class pointer to call the function.

18. what is synthesized in Objective-C ?

In Objective C  Once you have declared the property,then you have to tell the compiler instantly by using synthesize directive ,Which helps the  compiler to generate a getter &setter message.

19. How is string represented in Objective C ?

String is represented by using NSS string and its sub-class.   NSMutableString provides several ways for creating string objects.

20. How to call the function in Objective C ?

We can call the function by Account -> Object Name -> Display account information ->  Method name.

21. Explain Data encapsulation in  Objective C ?

It is referred to the mechanism of connecting the data and the functions that use them.

22. what are the classes used for to establish a connection between application to the web server ?

  • NSURL
  • NSURL REQUEST
  • NSURL CONNECTION

23. Explain what is the  use of category in Objective-C ?

It is used to extend an existing class by appending behavior that is useful only in  certain situations. Extensions and categorizes are used to add such extension to existing classes, Syntax to define a category is @interface keyword.

24. Explain whether NS object is a parent class or derived class ?

It is a parent class and consist of number of instance variable and instance methods.

25. Define how the class IMPLEMENTATION is represented in Objective C ?

IMPLEMENTATION is represented with @implementation directive and ends with @end.

 

 

 

 

Sharing is caring!

Comments are closed.