1. What is true regarding notifications?

Answers:

  1. They can be dispatched to only one object
  2. The object posting the notification does not even have to know whether the observer exists
  3. An object may receive any message you like from the notification center, not just the predefined delegate method
  4. All of the above
  5. None of the above

2. Which of the following retrieves the application main bundle?

Answers:

  1. [NSBundle mainBundle]
  2. [NSApplication mainBundle]
  3. [NSApp mainBundle]
  4. None of the above

3. Can you use NSLock on a POSIX mutex?

Answers:

  1. Yes
  2. No

4. If you spawn a thread with POSIX thread api, will Cocoa be notified?

Answers:

  1. Yes
  2. No

5. What method should be called before you are able to draw in the drawRect: method of a view?

Answers:

  1. None
  2. lockFocus
  3. lockView
  4. prepareDrawing
  5. None of the above

6. Which of the following creates an autoreleased array?

Answers:

  1. [NSMutableArray array];
  2. [NSMutableArray new];
  3. [[NSMutableArray alloc] init];

7. What class should be used to load resources?

Answers:

  1. NSResource
  2. NSApplication
  3. NSBundle
  4. NSFile
  5. None of the above

8. Can an object marked for autorelease be retained?

Answers:

  1. Yes
  2. No

9. What is a notification?

Answers:

  1. A user event
  2. A special message type used within the kernel
  3. An object that encapsulates information about an event
  4. None of the above

10. Fill the blank.

NSView : <> : NSObject

Answers:

  1. NSWindow
  2. NSResponder
  3. NSResponder : NSWindow
  4. NSRootView
  5. NSRoot

11. If you call interpretKeyEvents:, which of the following method is likely to be called?

Answers:

  1. collectEvent:
  2. dispatchEvent:
  3. sendEvent:
  4. insertText:/li>
  5. None of the above

12. Where is the (0,0) coordinate located on the screen?

Answers:

  1. top-left
  2. top-right
  3. bottom-left
  4. bottom-right
  5. center

13. What method should be called before you are able to draw outside the drawRect: method of a view?

Answers:

  1. None
  2. lockView
  3. lockFocus
  4. prepareView
  5. None of the above

14. What will be the output of the following code?

NSRect rect = NSMakeRect(0, 0, 10, 10);
NSRect *rect2 = malloc(sizeof(*rect2));
if(!rect2) {
NSLog(@”Not enough memory.”);
exit(EXIT_FAILURE);
}

*rect2 = rect;

printf(“%dn”, rect.size.width);

Answers:

  1. 0
  2. 10
  3. RUNTIME ERROR
  4. COMPILATION ERROR
  5. None of the above

15. Can NSBundle be used to load Java code?

Answers:

  1. Yes
  2. No

16. Under Mac OS X 10.5, CGRect, CGSize and CGPoint have the same structure as NSRect, NSSize and NSPoint respectively. Is it true?

Answers:

  1. Yes
  2. No

17. What is an observer?

Answers:

  1. An object that implements the NSObserver protocol
  2. An object that sends a notification
  3. An object that receives ALL notifications
  4. An object registered with the notification center
  5. None of the above

18. Does Cocoa support 64bits?

Answers:

  1. Yes
  2. No

19. Why is CGFloat recommenced to be used instead of float?

Answers:

  1. They are the same; so it’s done only to make the code look nicer.
  2. CGFloat is a special structure used to do arbitrary number computation.
  3. For 64bit compatibility.
  4. None of the above

20. Can resources be localized?

Answers:

  1. Yes
  2. No

21. Fill the blank.

NSMutableArray : <> : NSObject

Answers:

  1. NSSet
  2. NSCollection
  3. NSArray
  4. NSContainer
  5. NSMovableArray

22. What is NSRect?

Answers:

  1. A class
  2. An object
  3. A structure
  4. A C built in type
  5. An Objective-C built in type

23. Fill the blank.

NSCountedSet : <> : NSObject

Answers:

  1. NSArray : NSClass
  2. NSMutableArray : NSArray
  3. NSMutableSet : NSSet
  4. NSSet
  5. NSSet : NSArray

24. Can NSDistributedNotificationCenter be used to communicate between multiple machines?

Answers:

  1. Yes
  2. No

25. Is the following code correct?

NSMutableArray *a = [NSMutableArray new];

// do something with a

[a release];

Answers:

  1. Yes
  2. No

26. What threading API should be used in Cocoa?

Answers:

  1. CFThread
  2. pthread
  3. pth
  4. NSThread
  5. None of the above

27. Is the following code correct?

NSMutableArray *a = [NSMutableArray array];

// do something with a

[a release];

Answers:

  1. Yes
  2. No

28. How can you move a view?

Answers:

  1. You cannot
  2. By calling move: method
  3. By changing the frame with setFrame:
  4. None of the above

29. Fill the blank.
NSButton : <> : NSObject

Answers:

  1. NSControl :
  2. NSWidget : NSView : NSResponder
  3. NSResponder
  4. NSWidget
  5. NSControl : NSView : NSResponder

30. How is a GUI usually created in Cocoa?

Answers:

  1. With interface builder
  2. By editing xml files manually
  3. Programmatically
  4. None of the above

31. Is it possible to create events and dispatch them to the application?

Answers:

  1. Yes
  2. No

32. Can POSIX thread be used in Cocoa?

Answers:

  1. Yes
  2. No

33. Is it correct to have sibling views overlapping?

Answers:

  1. Yes
  2. No

34. Is the following code valid?

NSSize s = NSMakeSize(10, 10);

int values[20];

values[s.height] = 5;

Answers:

  1. Compile error
  2. Runtime error
  3. Valid code

35. In a typical Cocoa application, do you have to manage your runloop yourself?

Answers:

  1. Yes
  2. No

36. Is NSString mutable?

Answers:

  1. Yes
  2. No

37. Can you use malloc/free in a Cocoa application?

Answers:

  1. Yes
  2. Yes, but only in a separate C library
  3. Yes, but we can use only malloc; free is not needed
  4. No

38. What is NSViewHeightSizable constant used for?

Answers:

  1. Transparency
  2. Scrolling
  3. Autoresizing
  4. Magnification
  5. None of the above

39. Can poll() be used to fetch Cocoa events?

Answers:

  1. Yes
  2. No

40. What is a toll-free bridged class?

Answers:

  1. A superclass of another class
  2. A class that can be interchanged with another class by casting
  3. A wrapper around another class
  4. A class with no memory need
  5. None of the above

41. What is Cocoa?

Answers:

  1. A language
  2. A tree
  3. A system
  4. A framework
  5. None of the above

42. Is NSRunLoop thread safe?

Answers:

  1. Yes
  2. No

43. Which of the following platforms supports Cocoa?

Answers:

  1. Windows
  2. Linux
  3. Mac OSX
  4. Solaris
  5. None of the above

44. In which language is Cocoa written?

Answers:

  1. C
  2. Objective-C
  3. C++
  4. Java
  5. Ruby

45. Where should application resources be usually put?

Answers:

  1. In /System
  2. In /Library
  3. Within the application’s bundle
  4. In /Resources
  5. None of the above

46. Is there a double click event?

Answers:

  1. Yes
  2. No

47. Can an object be the delegate of multiple objects?

Answers:

Yes

No

48. Is it mandatory to create an NSAutoreleasePool in a Cocoa application?

Answers:

  1. Yes
  2. No

49. What is the normal way of handling Cocoa events?

Answers:

  1. By polling for events
  2. By registering an event watcher
  3. By implementing NSResponder methods in subclasses
  4. None of the above

50. Which of the following classes manages the computer’s global notifications?

Answers:

  1. NSNotificationCenter
  2. NSDistributedNotificationCenter
  3. NSGlobalNotificationCenter
  4. NSSystemNotificationCenter

51. Can a notified object find out from where the notification is coming? (Sending object)

Answers:

  1. Yes
  2. No

52. How wide is unichar on a 32bit machine?

Answers:

  1. 8bit
  2. 16bit
  3. 32bit
  4. 64bit
  5. 128bit

53. Is the following code correct?

NSRect a = NSMakeRect(0, 1, 2, 3) + NSMakeRect(0, 1, 2, 3);

Answers:

  1. Yes
  2. No

54. Fill the blank.

NSNotification : <> : NSObject

Answers:

  1. NSEvent
  2. NSCenter
  3. NSDistributed
  4. NSGeneralNotification
  5. Nothing is required to fill the blank

55. Is the following code valid?

NSRect r;

r.size = NSMakeSize(10, 10);
r.origin = NSMakePoint(-5, -5);

Answers:

  1. Yes
  2. No

56. Is the following code correct?

NSMutableArray *a = [[NSMutableArray new] autorelease];

// do something with a

[a release];

Answers:

  1. Yes
  2. No

57. What kind of memory management mechanisms can Cocoa uses?

Answers:

  1. Garbage collection
  2. Reference counting
  3. Manual memory management
  4. None of the above

58. Can you detach threads in Cocoa?

Answers:

  1. Yes
  2. No

59. Which of the following is a valid Uniform Type Identifier?

Answers:

  1. JPEG
  2. .jpg
  3. public.jpeg
  4. image/jpeg
  5. .jpeg

60. Is the following code correct?

– (void)myMethod:(NSString **)s {
*s = [[NSString alloc] init]:
}

Answers:

  1. Yes
  2. No

1,115 total views, 1 views today