Objective C MCQs

Objective C MCQs

The following Objective C MCQs have been compiled by our experts through research, in order to test your knowledge of the subject of Objective C. We encourage you to answer these multiple-choice questions to assess your proficiency.
Please continue by scrolling down.

1: True or False? You can compare two strings by (string1 == string2)

A.   False

B.   True

2: What is a dependency in NSOperationQueue?

A.   A dependency is a way to have an operation wait to be performed until the dependencies have been fulfilled/executed

B.   A dependency sets the variables of the NSOperationQueue

C.   A dependency is the alloc/init method of the NSOperationQueue

3: What is the Allocations instrument used for?

A.   Allows you to view your variable values

B.   A debugging tool that frees up memory

C.   Recording information from a single process about memory allocation

4: What is KVO?

A.   Key Value Operations

B.   Key Variable Obfuscation

C.   Key Value Observing

5: What is the difference between methods that begin with + and -?

A.   + methods are public, - methods are private

B.   Instance methods begin with - class level methods begin with +

C.   + methods are inheritable, - methods are not

6: Developers are allowed to call [super dealloc] in ARC.

A.   FALSE

B.   TRUE

7: What happens when you call retain on an object?

A.   It is released from memory

B.   It is permanently stored in memory

C.   You increase its retain count by 1

D.   It will stay in memory until the app closes

8: How can you declare a method, that can be set as the action to be performed on various events?

A.   - (IBAction) action:(id) sender;

B.   -(SEL) action:(id) event;

C.   -(selector) action:(id) sender;

9: What does a CAEmitterCell do?

A.   It defines the properties and direction of emitted particles from a CAEmitterLayer object.

B.   Nothing, it is not a valid class

C.   It is used by the GPS to track user coordinates and returns to values as coordinates

D.   It intercepts touch events

10: How do you free an object?

A.   free(obj)

B.   None of the above

C.   [obj free]

D.   [obj release]

E.   [obj dealloc]

11: What type of object is this under XCode 4.5: @[rabbit, chicken, owl]

A.   NSDictionary

B.   NSString

C.   SQLite schema

D.   NSArray

12: What is the method for adding KVO to your app?

A.   addKVO:forKey:

B.   addObserver:forKeyPath:options:context

C.   addListener:withContext:andObject:

13: To have an IOS app Screen Design we used which of the following tool?

A.   None of above

B.   Interface Xcode

C.   Interface Designer

D.   Interface builder

E.   Instruments

14: What does the "id" type mean?

A.   This is a type for a specific object of class id

B.   This is a type for strings

C.   This is the general type for any kind of object regardless of class

15: How do you concatenate two NSStrings *foo and NSString *bar to form a new NSString *baz?

A.   baz = [foo stringByAppendingString: bar];

B.   baz = [foo concat: bar];

C.   baz = foo + bar;

D.   baz = [foo appendString: bar];

E.   baz = foo & bar;

16: Which of the following is a Singleton?

A.   [NSArray array]

B.   [NSFileManager defaultManager]

17: What framework does the class UIButton come from?

A.   CoreGraphics

B.   Foundation

C.   OpenGLES

D.   EventKit

E.   UIKit

18: If you define a new class called Foo which inherits from NSObject, how do you create a new instance of it?

A.   Foo *temp = new Foo();

B.   Foo *temp = [[Foo alloc] init];

C.   Foo *temp = System.Create(Foo);

D.   Foo *temp = [Foo init];

E.   Foo *temp = Make Instance of Foo;

19: What does an Objective-C string literal look like?

A.   "foo"

B.   NSString("foo")

C.   $"foo"

D.   @"foo"

E.   #"foo"

20: ARC means?

A.   Artificial Reference Counting

B.   Application Reference Collection

C.   Access Reference Collation

D.   Angular Reference Courting

E.   Automatic Reference Counting

21: What is a delegate?

A.   A delegate holds the type of data a variable stores

B.   A delegate allows one NSObject to send messages to another NSObject, and listen to those messages

C.   A delegate is a UIView

D.   A delegate is a variable

22: Where is a MKAnnotationView used?

A.   In a button

B.   On a cell

C.   On a Map View

D.   On a table view

23: Which of the following is an object?

A.   float

B.   int

C.   NSNumber

D.   double

24: What is the name of the type of SQL Database that iOS Supports?

A.   SQLite

B.   SQL

C.   NoSql

D.   MySql

25: How do you get the Unicode character set of a Core Text font?

A.   CTFontCopyCharacterSet

B.   CTFontCopyFamilyName

C.   CTFontCopyDisplayName

26: What is used to sort Core Data results?

A.   NSCoreDataSort

B.   NSSortDescriptor

C.   NSSort

D.   [self sort]

27: True or False? A method and a variable can have the same name in Objective-C.

A.   False

B.   True

28: Which framework lets you determine the current location or heading associated with a device?

A.   NSLocation

B.   CFLocation

C.   CoreLocation

D.   MapKit

E.   LocationKit

29: How can you add a new method foo to an existing class Bar?

A.   Define a C function foo and then send Bar the extend:withSelector: message, e.g. [Bar extend: foo withSelector: @selector(foo:)].

B.   Both "extend" options are correct.

C.   Make a category, e.g. @interface Bar(Foo).

D.   It's not possible.

E.   Send Bar the "extend:" message, e.g. [Bar extend: foo].

30: If a class conforms to a protocol what must it do?

A.   Implement all methods in the protocol without exception

B.   Implement all methods in the protocol, except for optional ones

C.   Implement all methods which do not have a default implementation in the protocol

D.   Implement all or some methods and leave the rest to be implemented by subclasses

31: What is a design pattern?

A.   A template for a solution to a common problem faced by programmers.

B.   A methodology for approching database design.

C.   Coding standards used by an organization.

32: True or False? For an object to use constraints, it must have at least 3 constraint values.

A.   False

B.   True

33: Using UIViewController containment, which one of the following statements is true:

A.   Every viewcontroller can handle the loading and unloading of other viewcontroller.

B.   The root viewcontroller handles loading and unloading its child viewcontrollers.

34: What framework is KVO (key value observing) a part of?

A.   UIKit

B.   CoreData

C.   Foundation

35: Which of the following accesses a variable in structure b?

A.   b-var;

B.   b.var;

C.   b>var;

D.   b->var;

E.   b

36: let a:int=5 a=10 this code is true of false?

A.   true

B.   false

37: Can an exception caught in @ catch be re-thrown?

A.   Yes

B.   No

38: what does this code produce? [NSString] *myString = @"Hello World";

A.   gets SIGABRT while executing the application

B.   none of the above

C.   An Error during compile

D.   it put the value Hello World into a string named myString

E.   makes the pointer to myString equal to the pointer of the new created object with @"hello world"

39: True or False? Strings are one of the most common sources of buffer overflow attacks.

A.   False

B.   True

40: Does Objective-C have constructors and destructors?

A.   It depends on the object

B.   No, you use init and dealloc on Objective-C

C.   Yes

D.   Only NSStrings do

41: What is the type of @selector(foo)?

A.   None, that is not a valid Objective-C expression.

B.   SEL

C.   selector

D.   id

42: What class will allow you to use one or more blocks concurrently?

A.   NSConcurrentBlock

B.   NSBlock

C.   NSBlockOperation

D.   NSConcurrency

43: What is @dynamic directive meaning in iOS?

A.   The @dynamic directive generates setter method for your property at compile time.

B.   The @dynamic directive generates getter method for your property at compile time.

C.   The @dynamic directive generates the accessor methods for you at compile time.

D.   The @dynamic directive tells the compiler that you will provide accessor methods dynamically at runtime.

44: Are integers full-fledged objects in Objective-C?

A.   Integers are only partial objects in Objective-C (e.g. do not support any user defined methods).

B.   No, they are not objects at all.

C.   Yes.

D.   Yes, but only if you first cast them as id's, e.g. (id) 123.

45: Assume ARC is enabled... What would be another way to write this: NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @"Three",nil];

A.   NSArray *array = @{@"One", @"Two", @"Three"};

B.   NSArray *array = @[@"One", @"Two", @"Three"];

C.   NSArray *array = [@"One", @"Two",@"Three"];

D.   NSArray *array = {@"One", @"Two",@"Three"};

46: What happens at runtime with the following: NSObject* object = nil; NSObject* object2 = [object copy]; NSLog(@"%@", object2);

A.   object2 is instantiated as an NSObject with nil values

B.   Log prints "(null)" and continues as usual.

C.   Application crashes with "SIGABRT: object has been derferenced" error

D.   Application continues, but issues "cannot access nil object reference" warning

47: What is one source of particles that are emitted by a CAEmitterLayer object?

A.   A CAEmitterCell

B.   A UIEmitterView

C.   A NSEmitter

48: In Core Data, what is the name of an object representation of a record?

A.   NSManagedObject

B.   NSManageObjectContext

C.   NSManagedObjectModel

D.   NSEntityDescription

49: If you do not declare a return type for a method definition, what is the default return type?

A.   No return type

B.   id

C.   *NSString

50: What is the 'print object' command in the debugger window?

A.   po

B.   print

C.   -l

D.   p