Do you know that? 3.4M files are uploaded to workroom each year. That's more that 6 files a minute next

Contact Email: teammmrem@yahoo.com

<< All Upwork (oDesk) and Elance Tests << Upwork (oDesk) test answers << General Programming category

Test answers for Cocoa programming for Mac OS X 10.5 Test 2016

(60) Last updated: January 22
Upwork (oDesk) • General Programming
Questions and answers are regularly updated. Answered and not answered tests questions.

This helps getting job: Hundreds of (cover letter examples , interview questions , profile samples ) • Earn on Upwork (oDesk)
Job assistance: jobs popularityfreelance rates

Popular test answers: HTML, .Net, CSS, English, SEO, Photoshop, iOS, Java, Android, Ruby, Python, JavaScript

See all 6 tests answers updated

Find Upwork (oDesk) and Elance test answers on this website:



Collapse | Expand

60 Answered Test Questions:

1. What is true regarding notifications?

Answers:

• They can be dispatched to only one object

• The object posting the notification does not even have to know whether the observer exists

• An object may receive any message you like from the notification center, not just the predefined delegate method

• All of the above

• None of the above

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

Answers:

• [NSBundle mainBundle]

• [NSApplication mainBundle]

• [NSApp mainBundle]

• None of the above

3. Can you use NSLock on a POSIX mutex?

Answers:

• Yes

• No

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

Answers:

• Yes

• No

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

Answers:

• None

• lockFocus

• lockView

• prepareDrawing

• None of the above

6. Which of the following creates an autoreleased array?

Answers:

• [NSMutableArray array];

• [NSMutableArray new];

• [[NSMutableArray alloc] init];

7. What class should be used to load resources?

Answers:

• NSResource

• NSApplication

• NSBundle

• NSFile

• None of the above

8. Can an object marked for autorelease be retained?

Answers:

• Yes

• No

9. What is a notification?

Answers:

• A user event

• A special message type used within the kernel

• An object that encapsulates information about an event

• None of the above

10. Fill the blank.

NSView : <> : NSObject

Answers:

• NSWindow

• NSResponder

• NSResponder : NSWindow

• NSRootView

• NSRoot

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

Answers:

• collectEvent:

• dispatchEvent:

• sendEvent:

• insertText:

• None of the above

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

Answers:

• top-left

• top-right

• bottom-left

• bottom-right

• center

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

Answers:

• None

• lockView

• lockFocus

• prepareView

• 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("%d\n", rect.size.width);

Answers:

• 0

• 10

• RUNTIME ERROR

• COMPILATION ERROR

• None of the above

15. Can NSBundle be used to load Java code?

Answers:

• Yes

• 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:

• Yes

• No

17. What is an observer?

Answers:

• An object that implements the NSObserver protocol

• An object that sends a notification

• An object that receives ALL notifications

• An object registered with the notification center

• None of the above

18. Does Cocoa support 64bits?

Answers:

• Yes

• No

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

Answers:

• They are the same; so it's done only to make the code look nicer.

• CGFloat is a special structure used to do arbitrary number computation.

• For 64bit compatibility.

• None of the above

20. Can resources be localized?

Answers:

• Yes

• No

21. Fill the blank.

NSMutableArray : <> : NSObject

Answers:

• NSSet

• NSCollection

• NSArray

• NSContainer

• NSMovableArray

22. What is NSRect?

Answers:

• A class

• An object

• A structure

• A C built in type

• An Objective-C built in type

23. Fill the blank.

NSCountedSet : <>  : NSObject

Answers:

• NSArray : NSClass

• NSMutableArray : NSArray

• NSMutableSet : NSSet

• NSSet

• NSSet : NSArray

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

Answers:

• Yes

• No

25. Is the following code correct?

NSMutableArray *a = [NSMutableArray new];

// do something with a

[a release];

Answers:

• Yes

• No

26. What threading API should be used in Cocoa?

Answers:

• CFThread

• pthread

• pth

• NSThread

• None of the above

27. Is the following code correct?

NSMutableArray *a = [NSMutableArray array];

// do something with a

[a release];

Answers:

• Yes

• No

28. How can you move a view?

Answers:

• You cannot

• By calling move: method

• By changing the frame with setFrame:

• None of the above

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

Answers:

• NSControl :

• NSWidget : NSView : NSResponder

• NSResponder

• NSWidget

• NSControl : NSView : NSResponder

30. How is a GUI usually created in Cocoa?

Answers:

• With interface builder

• By editing xml files manually

• Programmatically

• None of the above

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

Answers:

• Yes

• No

32. Can POSIX thread be used in Cocoa?

Answers:

• Yes

• No

33. Is it correct to have sibling views overlapping?

Answers:

• Yes

• No

34. Is the following code valid?

NSSize s = NSMakeSize(10, 10);

int values[20];

values[s.height] = 5;

Answers:

• Compile error

• Runtime error

• Valid code

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

Answers:

• Yes

• No

36. Is NSString mutable?

Answers:

• Yes

• No

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

Answers:

• Yes

• Yes, but only in a separate C library

• Yes, but we can use only malloc; free is not needed

• No

38. What is NSViewHeightSizable constant used for?

Answers:

• Transparency

• Scrolling

• Autoresizing

• Magnification

• None of the above

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

Answers:

• Yes

• No

40. What is a toll-free bridged class?

Answers:

• A superclass of another class

• A class that can be interchanged with another class by casting

• A wrapper around another class

• A class with no memory need

• None of the above

41. What is Cocoa?

Answers:

• A language

• A tree

• A system

• A framework

• None of the above

42. Is NSRunLoop thread safe?

Answers:

• Yes

• No

43. Which of the following platforms supports Cocoa?

Answers:

• Windows

• Linux

• Mac OSX

• Solaris

• None of the above

44. In which language is Cocoa written?

Answers:

• C

• Objective-C

• C++

• Java

• Ruby

45. Where should application resources be usually put?

Answers:

• In /System

• In /Library

• Within the application's bundle

• In /Resources

• None of the above

46. Is there a double click event?

Answers:

• Yes

• 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:

• Yes

• No

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

Answers:

• By polling for events

• By registering an event watcher

• By implementing NSResponder methods in subclasses

• None of the above

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

Answers:

• NSNotificationCenter

• NSDistributedNotificationCenter

• NSGlobalNotificationCenter

• NSSystemNotificationCenter

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

Answers:

• Yes

• No

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

Answers:

• 8bit

• 16bit

• 32bit

• 64bit

• 128bit

53. Is the following code correct?

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

Answers:

• Yes

• No

54. Fill the blank.

NSNotification : <> : NSObject

Answers:

• NSEvent

• NSCenter

• NSDistributed

• NSGeneralNotification

• 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:

• Yes

• No

56. Is the following code correct?

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

// do something with a

[a release];

Answers:

• Yes

• No

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

Answers:

• Garbage collection

• Reference counting

• Manual memory management

• None of the above

58. Can you detach threads in Cocoa?

Answers:

• Yes

• No

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

Answers:

• JPEG

• .jpg

• public.jpeg

• image/jpeg

• .jpeg

60. Is the following code correct?

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

Answers:

• Yes

• No