Upwork Cocoa programming for Mac OS X 10.5 Test 2016.
60 Answered Test Questions:
1. What is true regarding notifications?
Answers:
a. They can be dispatched to only one object
a. The object posting the notification does not even have to know whether the observer exists
a. An object may receive any message you like from the notification center, not just the predefined delegate method
a. All of the above
a. None of the above
2. Which of the following retrieves the application main bundle?
Answers:
a. [NSBundle mainBundle]
a. [NSApplication mainBundle]
a. [NSApp mainBundle]
a. None of the above
3. Can you use NSLock on a POSIX mutex?
Answers:
a. Yes
a. No
4. If you spawn a thread with POSIX thread api, will Cocoa be notified?
Answers:
a. Yes
a. No
5. What method should be called before you are able to draw in the drawRect: method of a view?
Answers:
a. None
a. lockFocus
a. lockView
a. prepareDrawing
a. None of the above
6. Which of the following creates an autoreleased array?
Answers:
a. [NSMutableArray array];
a. [NSMutableArray new];
a. [[NSMutableArray alloc] init];
7. What class should be used to load resources?
Answers:
a. NSResource
a. NSApplication
a. NSBundle
a. NSFile
a. None of the above
8. Can an object marked for autorelease be retained?
Answers:
a. Yes
a. No
9. What is a notification?
Answers:
a. A user event
a. A special message type used within the kernel
a. An object that encapsulates information about an event
a. None of the above
10. Fill the blank.
1. What is true regarding notifications?
Answers:
a. They can be dispatched to only one object
a. The object posting the notification does not even have to know whether the observer exists
a. An object may receive any message you like from the notification center, not just the predefined delegate method
a. All of the above
a. None of the above
2. Which of the following retrieves the application main bundle?
Answers:
a. [NSBundle mainBundle]
a. [NSApplication mainBundle]
a. [NSApp mainBundle]
a. None of the above
3. Can you use NSLock on a POSIX mutex?
Answers:
a. Yes
a. No
4. If you spawn a thread with POSIX thread api, will Cocoa be notified?
Answers:
a. Yes
a. No
5. What method should be called before you are able to draw in the drawRect: method of a view?
Answers:
a. None
a. lockFocus
a. lockView
a. prepareDrawing
a. None of the above
6. Which of the following creates an autoreleased array?
Answers:
a. [NSMutableArray array];
a. [NSMutableArray new];
a. [[NSMutableArray alloc] init];
7. What class should be used to load resources?
Answers:
a. NSResource
a. NSApplication
a. NSBundle
a. NSFile
a. None of the above
8. Can an object marked for autorelease be retained?
Answers:
a. Yes
a. No
9. What is a notification?
Answers:
a. A user event
a. A special message type used within the kernel
a. An object that encapsulates information about an event
a. None of the above
10. Fill the blank.
NSView : <> : NSObject
Answers:
a. NSWindow
a. NSResponder
a. NSResponder : NSWindow
a. NSRootView
a. NSRoot
11. If you call interpretKeyEvents:, which of the following method is likely to be called?
Answers:
a. collectEvent:
a. dispatchEvent:
a. sendEvent:
a. insertText:
a. None of the above
12. Where is the (0,0) coordinate located on the screen?
Answers:
a. top-left
a. top-right
a. bottom-left
a. bottom-right
a. center
13. What method should be called before you are able to draw outside the drawRect: method of a view?
Answers:
a. None
a. lockView
a. lockFocus
a. prepareView
a. None of the above
14. What will be the output of the following code?
Answers:
a. NSWindow
a. NSResponder
a. NSResponder : NSWindow
a. NSRootView
a. NSRoot
11. If you call interpretKeyEvents:, which of the following method is likely to be called?
Answers:
a. collectEvent:
a. dispatchEvent:
a. sendEvent:
a. insertText:
a. None of the above
12. Where is the (0,0) coordinate located on the screen?
Answers:
a. top-left
a. top-right
a. bottom-left
a. bottom-right
a. center
13. What method should be called before you are able to draw outside the drawRect: method of a view?
Answers:
a. None
a. lockView
a. lockFocus
a. prepareView
a. 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);
}
NSRect *rect2 = malloc(sizeof(*rect2));
if(!rect2) {
NSLog(@”Not enough memory.”);
exit(EXIT_FAILURE);
}
*rect2 = rect;
printf(“%d\n”, rect.size.width);
Answers:
a. 0
a. 10
a. RUNTIME ERROR
a. COMPILATION ERROR
a. None of the above
15. Can NSBundle be used to load Java code?
Answers:
a. Yes
a. 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:
a. Yes
a. No
17. What is an observer?
Answers:
a. An object that implements the NSObserver protocol
a. An object that sends a notification
a. An object that receives ALL notifications
a. An object registered with the notification center
a. None of the above
18. Does Cocoa support 64bits?
Answers:
a. Yes
a. No
19. Why is CGFloat recommenced to be used instead of float?
Answers:
a. They are the same; so it’s done only to make the code look nicer.
a. CGFloat is a special structure used to do arbitrary number computation.
a. For 64bit compatibility.
a. None of the above
20. Can resources be localized?
Answers:
a. Yes
a. No
21. Fill the blank.
Answers:
a. 0
a. 10
a. RUNTIME ERROR
a. COMPILATION ERROR
a. None of the above
15. Can NSBundle be used to load Java code?
Answers:
a. Yes
a. 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:
a. Yes
a. No
17. What is an observer?
Answers:
a. An object that implements the NSObserver protocol
a. An object that sends a notification
a. An object that receives ALL notifications
a. An object registered with the notification center
a. None of the above
18. Does Cocoa support 64bits?
Answers:
a. Yes
a. No
19. Why is CGFloat recommenced to be used instead of float?
Answers:
a. They are the same; so it’s done only to make the code look nicer.
a. CGFloat is a special structure used to do arbitrary number computation.
a. For 64bit compatibility.
a. None of the above
20. Can resources be localized?
Answers:
a. Yes
a. No
21. Fill the blank.
NSMutableArray : <> : NSObject
Answers:
a. NSSet
a. NSCollection
a. NSArray
a. NSContainer
a. NSMovableArray
22. What is NSRect?
Answers:
a. A class
a. An object
a. A structure
a. A C built in type
a. An Objective-C built in type
23. Fill the blank.
Answers:
a. NSSet
a. NSCollection
a. NSArray
a. NSContainer
a. NSMovableArray
22. What is NSRect?
Answers:
a. A class
a. An object
a. A structure
a. A C built in type
a. An Objective-C built in type
23. Fill the blank.
NSCountedSet : <> : NSObject
Answers:
a. NSArray : NSClass
a. NSMutableArray : NSArray
a. NSMutableSet : NSSet
a. NSSet
a. NSSet : NSArray
24. Can NSDistributedNotificationCenter be used to communicate between multiple machines?
Answers:
a. Yes
a. No
25. Is the following code correct?
Answers:
a. NSArray : NSClass
a. NSMutableArray : NSArray
a. NSMutableSet : NSSet
a. NSSet
a. NSSet : NSArray
24. Can NSDistributedNotificationCenter be used to communicate between multiple machines?
Answers:
a. Yes
a. No
25. Is the following code correct?
NSMutableArray *a = [NSMutableArray new];
// do something with a
[a release];
Answers:
a. Yes
a. No
26. What threading API should be used in Cocoa?
Answers:
a. CFThread
a. pthread
a. pth
a. NSThread
a. None of the above
27. Is the following code correct?
Answers:
a. Yes
a. No
26. What threading API should be used in Cocoa?
Answers:
a. CFThread
a. pthread
a. pth
a. NSThread
a. None of the above
27. Is the following code correct?
NSMutableArray *a = [NSMutableArray array];
// do something with a
[a release];
Answers:
a. Yes
a. No
28. How can you move a view?
Answers:
a. You cannot
a. By calling move: method
a. By changing the frame with setFrame:
a. None of the above
29. Fill the blank.
NSButton : <> : NSObject
Answers:
a. NSControl :
a. NSWidget : NSView : NSResponder
a. NSResponder
a. NSWidget
a. NSControl : NSView : NSResponder
30. How is a GUI usually created in Cocoa?
Answers:
a. With interface builder
a. By editing xml files manually
a. Programmatically
a. None of the above
31. Is it possible to create events and dispatch them to the application?
Answers:
a. Yes
a. No
32. Can POSIX thread be used in Cocoa?
Answers:
a. Yes
a. No
33. Is it correct to have sibling views overlapping?
Answers:
a. Yes
a. No
34. Is the following code valid?
Answers:
a. Yes
a. No
28. How can you move a view?
Answers:
a. You cannot
a. By calling move: method
a. By changing the frame with setFrame:
a. None of the above
29. Fill the blank.
NSButton : <> : NSObject
Answers:
a. NSControl :
a. NSWidget : NSView : NSResponder
a. NSResponder
a. NSWidget
a. NSControl : NSView : NSResponder
30. How is a GUI usually created in Cocoa?
Answers:
a. With interface builder
a. By editing xml files manually
a. Programmatically
a. None of the above
31. Is it possible to create events and dispatch them to the application?
Answers:
a. Yes
a. No
32. Can POSIX thread be used in Cocoa?
Answers:
a. Yes
a. No
33. Is it correct to have sibling views overlapping?
Answers:
a. Yes
a. No
34. Is the following code valid?
NSSize s = NSMakeSize(10, 10);
int values[20];
values[s.height] = 5;
Answers:
a. Compile error
a. Runtime error
a. Valid code
35. In a typical Cocoa application, do you have to manage your runloop yourself?
Answers:
a. Yes
a. No
36. Is NSString mutable?
Answers:
a. Yes
a. No
37. Can you use malloc/free in a Cocoa application?
Answers:
a. Yes
a. Yes, but only in a separate C library
a. Yes, but we can use only malloc; free is not needed
a. No
38. What is NSViewHeightSizable constant used for?
Answers:
a. Transparency
a. Scrolling
a. Autoresizing
a. Magnification
a. None of the above
39. Can poll() be used to fetch Cocoa events?
Answers:
a. Yes
a. No
40. What is a toll-free bridged class?
Answers:
a. A superclass of another class
a. A class that can be interchanged with another class by casting
a. A wrapper around another class
a. A class with no memory need
a. None of the above
41. What is Cocoa?
Answers:
a. A language
a. A tree
a. A system
a. A framework
a. None of the above
42. Is NSRunLoop thread safe?
Answers:
a. Yes
a. No
43. Which of the following platforms supports Cocoa?
Answers:
a. Windows
a. Linux
a. Mac OSX
a. Solaris
a. None of the above
44. In which language is Cocoa written?
Answers:
a. C
a. Objective-C
a. C++
a. Java
a. Ruby
45. Where should application resources be usually put?
Answers:
a. In /System
a. In /Library
a. Within the application’s bundle
a. In /Resources
a. None of the above
46. Is there a double click event?
Answers:
a. Yes
a. No
47. Can an object be the delegate of multiple objects?
Answers:
a. Yes
a. No
48. Is it mandatory to create an NSAutoreleasePool in a Cocoa application?
Answers:
a. Yes
a. No
49. What is the normal way of handling Cocoa events?
Answers:
a. By polling for events
a. By registering an event watcher
a. By implementing NSResponder methods in subclasses
a. None of the above
50. Which of the following classes manages the computer’s global notifications?
Answers:
a. NSNotificationCenter
a. NSDistributedNotificationCenter
a. NSGlobalNotificationCenter
a. NSSystemNotificationCenter
51. Can a notified object find out from where the notification is coming? (Sending object)
Answers:
a. Yes
a. No
52. How wide is unichar on a 32bit machine?
Answers:
a. 8bit
a. 16bit
a. 32bit
a. 64bit
a. 128bit
53. Is the following code correct?
Answers:
a. Compile error
a. Runtime error
a. Valid code
35. In a typical Cocoa application, do you have to manage your runloop yourself?
Answers:
a. Yes
a. No
36. Is NSString mutable?
Answers:
a. Yes
a. No
37. Can you use malloc/free in a Cocoa application?
Answers:
a. Yes
a. Yes, but only in a separate C library
a. Yes, but we can use only malloc; free is not needed
a. No
38. What is NSViewHeightSizable constant used for?
Answers:
a. Transparency
a. Scrolling
a. Autoresizing
a. Magnification
a. None of the above
39. Can poll() be used to fetch Cocoa events?
Answers:
a. Yes
a. No
40. What is a toll-free bridged class?
Answers:
a. A superclass of another class
a. A class that can be interchanged with another class by casting
a. A wrapper around another class
a. A class with no memory need
a. None of the above
41. What is Cocoa?
Answers:
a. A language
a. A tree
a. A system
a. A framework
a. None of the above
42. Is NSRunLoop thread safe?
Answers:
a. Yes
a. No
43. Which of the following platforms supports Cocoa?
Answers:
a. Windows
a. Linux
a. Mac OSX
a. Solaris
a. None of the above
44. In which language is Cocoa written?
Answers:
a. C
a. Objective-C
a. C++
a. Java
a. Ruby
45. Where should application resources be usually put?
Answers:
a. In /System
a. In /Library
a. Within the application’s bundle
a. In /Resources
a. None of the above
46. Is there a double click event?
Answers:
a. Yes
a. No
47. Can an object be the delegate of multiple objects?
Answers:
a. Yes
a. No
48. Is it mandatory to create an NSAutoreleasePool in a Cocoa application?
Answers:
a. Yes
a. No
49. What is the normal way of handling Cocoa events?
Answers:
a. By polling for events
a. By registering an event watcher
a. By implementing NSResponder methods in subclasses
a. None of the above
50. Which of the following classes manages the computer’s global notifications?
Answers:
a. NSNotificationCenter
a. NSDistributedNotificationCenter
a. NSGlobalNotificationCenter
a. NSSystemNotificationCenter
51. Can a notified object find out from where the notification is coming? (Sending object)
Answers:
a. Yes
a. No
52. How wide is unichar on a 32bit machine?
Answers:
a. 8bit
a. 16bit
a. 32bit
a. 64bit
a. 128bit
53. Is the following code correct?
NSRect a = NSMakeRect(0, 1, 2, 3) + NSMakeRect(0, 1, 2, 3);
Answers:
a. Yes
a. No
54. Fill the blank.
Answers:
a. Yes
a. No
54. Fill the blank.
NSNotification : <> : NSObject
Answers:
a. NSEvent
a. NSCenter
a. NSDistributed
a. NSGeneralNotification
a. Nothing is required to fill the blank
55. Is the following code valid?
Answers:
a. NSEvent
a. NSCenter
a. NSDistributed
a. NSGeneralNotification
a. 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:
a. Yes
a. No
56. Is the following code correct?
r.origin = NSMakePoint(-5, -5);
Answers:
a. Yes
a. No
56. Is the following code correct?
NSMutableArray *a = [[NSMutableArray new] autorelease];
// do something with a
[a release];
Answers:
a. Yes
a. No
57. What kind of memory management mechanisms can Cocoa uses?
Answers:
a. Garbage collection
a. Reference counting
a. Manual memory management
a. None of the above
58. Can you detach threads in Cocoa?
Answers:
a. Yes
a. No
59. Which of the following is a valid Uniform Type Identifier?
Answers:
a. JPEG
a. .jpg
a. public.jpeg
a. image/jpeg
a. .jpeg
60. Is the following code correct?
Answers:
a. Yes
a. No
57. What kind of memory management mechanisms can Cocoa uses?
Answers:
a. Garbage collection
a. Reference counting
a. Manual memory management
a. None of the above
58. Can you detach threads in Cocoa?
Answers:
a. Yes
a. No
59. Which of the following is a valid Uniform Type Identifier?
Answers:
a. JPEG
a. .jpg
a. public.jpeg
a. image/jpeg
a. .jpeg
60. Is the following code correct?
– (void)myMethod:(NSString **)s {
*s = [[NSString alloc] init]:
}
Answers:
a. Yes
a. No
*s = [[NSString alloc] init]:
}
Answers:
a. Yes
a. No
No comments:
Post a Comment