Upwork/oDesk iPhone Programming OS 2.1 Test



1. Which of the following languages can be used to write the code for Xcode projects?
Answers:
• C
• C++
• Objective-C
• Objective-C++
• Java

2. Which of the following need to be modified while localizing an application?
Answers:
• Nib files (windows, views, menus).
• Static text.
• Icons and graphics.
• Dynamic text generated by your program.
3. Which of the following directives are used to declare and define classes, categories, and protocols?
Answers:
• @interface
• @implementation
• @protocol
• @class
• @end
4. Which of the following statements regarding Objective-C are correct?
Answers:
• In Objective-C, the keyword for NULL is nil.
• In Objective-C, #import and #include compiler directives carry out the same operations.
• In Objective-C, for the object-oriented constructs (such as method return values), id is the default data type.
• The keyword nil has an id with a value of 0.
5. Which of the following are valid touch attributes in a UITouch class object?
Answers:
• locationInView
• timestamp
• phase
• tapCount
6. Which of the following statements comply with the fundamental rules of Memory Management in Objective-C?
Answers:
• The ownership of the object is taken when it is created using a method the name of which begins with alloc or new or contains copy.
• The ownership of the objects is relinquished by using release or autorelease
• All other objects can also be released from memory using the release function.
• autorelease just means - send a release message later
7. The genstrings tool can parse _____.
Answers:
• C files with .c filename extension.
• Objective-C files with .m filename extension.
• Java code files with .java filename extension.
• Nib files with any file name extension.
8. Which of the following are the Derivative types defined in Objective-C?
Answers:
• short
• long
• long long
• int
9. Which of the following options regarding UIWindow and UIView classes are correct?
Answers:
• A UIWindow class object holds the contents of a UIView class object.
• A UIWindow class object can hold multiple sub-objects whereas a UIView class object can hold only one sub-object.
• Both UIWindow and UIView classes are required to display anything on the iPhone.
• UIWindow is the iPhone's base window class and the UIView class is primarily an abstract super-class.
10. Which of the following statements regarding Memory Management are correct?
Answers:
• The alloc method creates a new object and returns it with a reference count of 1
• retain does not change the receiver's reference count
• release decreases the receiver's reference count by 1
• autorelease decreases the receiver's reference count by 1 at some point in the future
• copy makes a copy of an object and increases the reference count by 1
11. Which of the following events occur when the retain count of the object drops to 0?
Answers:
• The release method is fired to relinquish the ownership of the object.
• The object is deallocated.
• The dealloc method is invoked automatically
• The resources associated with it are disposed
12. Which of the following SDK classes can be used to get the location of the movement of a finger on the iPhone screen?
Answers:
• UINavigationController
• UIEvent
• UITouch
• UIView
13. You have added the following code lines in your @implementation block in your ControllerView file:

        @synthesize textField;
        @synthesize label;
        @synthesize string;

And in your dealloc method, you have added the following code lines:

        - (void)dealloc {
            [textField release];
            [label release];
            [string release];
            [super dealloc];
        }

What is the purpose of adding the above lines in your dealloc method?
Answers:
• To release the instance variables
• To conform to the rules of memory management
• To make the variables available for reuse in application
• To terminate the program
14. Which of the following terms are related to Memory Management in Objective-C?
Answers:
• alloc
• mutableCopy
• delete
• release
15. In your iPhone application, you want to apply an action sheet style that will display white text with transparent black background whenever a confirmation is required from the user. You have a UIActionSheet class object named "actionuser". Which of the following code snippets is the right one for applying this style?
Answers:
• [ actionuser setActionSheetStyle: 0 ];
• [ actionuser setActionSheetStyle: 1 ];
• [ actionuser setActionSheetStyle: 2 ];
• [ actionuser setActionSheetStyle: 3 ];
16. Is NSMutableArray thread safe?
Answers:
• Yes
• No
17. What is the purpose of active executable in an Xcode project?
Answers:
• To specify which program is launched and how, when you run or debug from within Xcode.
• To select the appropriate configuration of the active target and each target it depends upon while building.
• To define different build configurations for different circumstances such as development or release.
• To build products for Multiple Platforms.
18. Which of the following samples returns the first name of a person listed under p in the address book?
Answers:
• ABPersonGetValue(p, kABFirstNameProperty);
• ABPersonCopyValue(p, kABFirstNameProperty);
• ABRecordGetValue(p, kABPersonFirstNameProperty);
• ABRecordCopyValue(p, kABPersonFirstNameProperty);
• [p firstName];
19. In which file is the following function called in your application?
       
        int retVal = UIApplicationMain(argc, argv, nil, nil);
Answers:
• info.plist
• Any file with .m extension
• main.m only
• Any file with .h extension
• ControllerView file
• Nib file
20. State whether the following statement is true or false:

Interface Builder doesn't generate source code
Answers:
• True
• False
21. Can you place calls using the iPhone SDK?
Answers:
• Yes
• No
22. Can you use POSIX threads on the iPhone?
Answers:
• Yes
• No
23. Which of the following is the correct syntax for declaring a class in Objective-C?
Answers:
• @interface ClassName : ItsSuperclass { instance variable declarations } method declarations @end
• @implementation ClassName : ItsSuperclass { instance variable declarations } method declarations @end
• @class ClassName : ItsSuperclass { instance variable declarations } method declarations @end
• All are correct
24. Locking all connections before editing the Nib files can be achieved by using:
Answers:
• An option in the Start Menu.
• An option in the Preferences panel of Interface Builder.
• An option in the Preferences panel of Language Directory.
• Any of the above.
25. What is the endianness of the network for IP communications?
Answers:
• Big endian
• Little endian
• Mixed endian
• Swapped endian
• Single endian
26. What is the screen resolution of the iPhone 3G?
Answers:
• 720x540
• 480x320
• 320x240
• 540x280
• 540x480
27. Which of the following methods does the UIKit provide in order to draw a string at a specific point.
Answers:
• NSString
• drawAtPoint:
• drawAsPatternInRect
• All of the above
28. From which of the following classes does a UITextView class object inherit its features?
Answers:
• UIScroller
• UIView
• UIControl
• UITextField
29. Which of the following can be used to draw a tiled image?
Answers:
• Quartz 2D function CGContextDrawTiledImage
• UIViews
• Either a or b
• Neither a not b
30. In your iPhone application, you want that the user should be able to select the date in Month, Day and Year mode. You have a UIDatePicker class object named dateModePicker. Which of the following code snippets is correct in order to apply this mode?
Answers:
• [ dateModePicker setDatePickerMode: 0 ];
• [ dateModePicker setDatePickerMode: 1 ];
• [ dateModePicker setDatePickerMode: 2 ];
• [ dateModePicker setDatePickerMode: 3 ];
31. Which of the following is the base class for all iPhone applications?
Answers:
• UIActionSheet
• UIApplication
• UIControl
• UIApplicationDelegate
32. In the CALayer class, the property contentsGravity allows you to position and scale the layer's contents image within the layer bounds. What is the role of the kCAGravityLeft positioning constant in contentsGravity?
Answers:
• It positions the content image in the top left corner of the layer.
• It positions the content image vertically centered on the left edge of the layer.
• It positions the content image in the bottom left corner of the layer.
• It positions the content image at the center of the layer.
33. Before editing the Nibs, one should:
Answers:
• Unlock all connections.
• Lock all connections.
• Break all connections.
• None of the above
34. Given the string "192.168.1.1", how can you get an integer address (to fill a sockaddr_in structure)?
Answers:
• With inet_ntoa
• With inet_aton
• With NSString
• All addresses are in ASCII format
• None of the above
35. Can you use POSIX sockets on the iPhone?
Answers:
• Yes
• No
36. If you want to know if a host is reachable via the network, what would you use in your application?
Answers:
• ping
• NSURL isReachable: method
• NSNetwork discover: method
• SCNetworkReachabilityCreateWithName
• None of the above
37. What happens if Xcode is not able to find a file or folder at the path defined for it in the project?
Answers:
• Xcode skips the file or the folder and continues execution.
• Xcode gives an alert with a description of the missing file.
• Xcode displays the item in red in the project window.
38. In which language is the address book framework written?
Answers:
• Objective-C
• C
• C++
• Ruby
• Java
39. When the genstrings tool discovers a key string used more than once in a single strings file, it:
Answers:
• deletes the comments from the individual entries and leaves one comment string without generating a warning.
• merges the comments from the individual entries into one comment string and generates a warning.
• differentiates the comments from the individual entries into various strings and generates a warning.
• None of the above
40. Which of the following classes is used to internalize an XML into a logical tree structure?
Answers:
• NSData class
• NSXMLDocument class
• NSXMLNode class
• NSPropertyListSerialization class
41. What is the CompressResources build step in an iPhone Xcode project?
Answers:
• It resizes all the files in the project for displaying them in the iPhone.
• It resizes the png files in the project for displaying them in the iPhone.
• It compresses the files with the extensions .m and .h.
• It changes the extension of the files and compresses them.
42. Can CGGradientRef be used on the iPhone to draw gradients?
Answers:
• Yes
• No
43. While using an iPhone, a user switches from one application to another application or service on the device. What is the most important factor to be kept in mind to ensure that your application reflects the most recent changes made by the user the next time it starts?
Answers:
• The user should be asked to click save and close from the start menu
• The user should be asked to close your application
• The application should be programmed to save any user changes as they are made as quickly as possible.
• No specific consideration in this regard is necessary
44. Which of the following debugging environments are provided by Xcode to find and squash bugs in your code?
Answers:
• Debugging from the text editor
• Mini Debugger
• Debugger window
• GDB debugger console
• All of the above
45. On the iPhone, what are the types of Person entries and Group entries?
Answers:
• ABPersonRef and ABGroupRef
• ABPerson and ABGroup
• ABRecordRef and ABRecordRef
• ABRecord and ABRecord
• None of the above
46. How do you play a short sound on the iPhone?
Answers:
• With the NSSound class
• With the UISound class
• With AudioServicesPlaySystemSound function
• With NSSystemSound function
• None of the above
47. What is the function of the Code Sense feature in Xcode?
Answers:
• Code Sense helps in switching between different circumstances such as development or release.
• Code Sense maintains an index that contains important information for your project.
• Code Sense creates a cache for the files which are being used frequently.
• Code Sense maintains an index of files used in a project.
48. Whenever the iPhone users switch to another application like answering the phone, or checking their email, the application they were previously using _____.
Answers:
• quits
• keeps running
• resumes as soon as the other application is terminated
• may or may not resume depending on the application
49. Does ABPersonCreate function add the newly created record into the address book?
Answers:
• Yes
• No
50. How can you prevent a view from receiving touch events?
Answers:
• By overriding UIResponder relevant methods
• By setting userInteractionEnabled to false
• By setting shouldDeliverEvent to false
• You can't
• None of the above
51. Which of the following is true?
Answers:
• An application thread can have only one NSAutoreleasePool
• NSAutoreleasePool is thread safe
• NSAutoreleasePool should not be used outside the main thread
• Each thread maintains its own stack of NSAutoreleasePool objects
• None is true
52. Refer to the given image:

Which of the above window panes will display Build system output when Xcode builds your target and shows the corresponding warnings and errors?
Answers:
• A
• B
• C
• None of the above
53. Which of the following classes automatically manages transition
animation between Views?
Answers:
• UIAnimationController
• UIViewAnimation
• CGViewAnimation
• UIApplicationDelegate
• UINavigationController
54. Which of the following is not a touch event method?
Answers:
• - (void)touchesDragged:(NSSet *)touches withEvent:(UIEvent *)event;
• - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
• - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
• - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
• - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
55. How many windows does an iPhone application typically have?
Answers:
• 0
• 1
• 2
• 10
• None of the above
56. Which of the following shapes is generated by Views in an iPhone?
Answers:
• Rectangular
• Square
• Rhombus
• All of the above
57. How can you restrict the delivery of multi-touch events to their subviews
Answers:
• You can't
• By manually redirecting events from the event handlers
• By overriding hitTest:withEvent:
• By registering the subview in the notification center
• None of the above
58. Using the following function, what will you get from the default database?

NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0];
Answers:
• The list of preferred languages.
• The user's preferred language.
• The user's default language.
• The list of languages supported by the application.
59. Which of the following should be used to draw 3D content?
Answers:
• OpenGL
• OpenGL ES
• Direct 3D
• None of the above
60. Which of the following is a feature of CAPropertyAnimation class in Core Animation?
Answers:
• It is an abstract subclass that provides support for animating a layer property specified by a key path
• It allows an array of animation objects to be grouped together and run concurrently
• It provides simple interpolation for a layer property
• It provides a transition effect that affects the entire layer's content. It fades, pushes, or reveals layer content when animating
61. While recording a sound, how can you know if the source of the sound is from the built-in microphone or headphone microphone?
Answers:
• With the NSSound class method named audioSource
• With the AudioQueueGetParameters function
• By querying the registry
• By polling for audio events
• iPhone OS 2.1 version does not support sound recording.
62. Can non-main threads poll for events?
Answers:
• Yes
• No
63. What can trigger a call to touchesCancelled:withEvent: ?
Answers:
• The user lifting all fingers from the phone
• A system event, such as a phone call
• The user lifting one or more fingers from the phone
• This method doesn't exist
• None of the above
64. In which of the following classes are the addChild, insertChild, and removeChildAtIndex methods defined?
Answers:
• NSXMLElement Class
• NSXMLNode Class
• NSXMLDocument class
• NSPropertyListSerialization class
65. While opening Nib files, which of the following should not be ignored?
Answers:
• Objects in a Nib file typically have connections between them that should not be broken.
• If Objects in a Nib file have broken connections, they should not be restored.
• The size of the files.
• None of the above
66. What does CFSocketGetNative return?
Answers:
• A CF opaque type
• A POSIX socket handle
• A native Cocoa object
• A binary representation of the socket incoming data in machine native endian
• None of the above
67. Are instances of ABAddressBookRef thread safe?
Answers:
• Yes
• No
68. Which of the following best describes View Controllers?
Answers:
• View Controllers provide access to data.
• View Controllers implement Views' inner logic.
• View Controllers regulate Views' animations.
• View Controllers provide the basic user interface logic for presenting numerous application views to the user.
• None of the above
69. Is NSRunLoop thread safe?
Answers:
• Yes
• No
70. What is the default value for the anchorPoint property in Layer Geometry?
Answers:
• (0.0,0.0)
• (0.0,0.5)
• (0.5,0.0)
• (0.5,0.5)
• (1.0,1.0)
71. Can the iPhone use Bonjour messaging?
Answers:
• Yes
• No
72. Which of the following debugging tasks are provided by Xcode to find and squash bugs in your code?
Answers:
• Add and set breakpoints.
• View your call stack per thread.
• View the value of variables by hovering the mouse pointer over them.
• Execute a single line of code.
• All of the above
73. If the code is written using the Core Foundation and Foundation macros, the simplest way to create strings files is:
Answers:
• Using an option in the Preferences panel of Interface Builder.
• By merging the comments from the individual entries into one comment string.
• By unlocking all connections.
• By using the genstrings command-line tool.
74. Which type of data is returned by the following function?

   CFDataRef CreateDataFromImage(UIImage *image)

{
    return CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage));
}
Answers:
• Binary image data.
• Raw pixel data.
• Compressed image data.
• ASCII image data.
75. How can you play video on the iPhone from your application?
Answers:
• With QuickTime
• With OpenGL ES
• With the MediaPlayer framework
• With VideoCodecServices
76. If you try to run an application in the iPhone Simulator without having created the ControllerView Nib file, what will happen?
Answers:
• The application will crash
• The application will run smoothly
• If you set the Nib file name to nil using initWithNibName:nil, the application will run
• The application will take time to load
77. Which design pattern for your application periodically sends messages to another object to ask for input or to notify that an event is occurring?
Answers:
• Model-View-Controller
• Delegation
• Target-action
78. Choose the correct statement:
To "flip" your user interface:
Answers:
• use the standardViewTransition:forInterface:Cache: method of the UIView class, and provide the appropriate constant to specify the flip direction.
• use the setAnimationTransition:forView:Cache: method of the UIView class, and provide the appropriate constant to specify the flip direction.
• use the setUICatalog:forView:Cache: method of the UIView class reference, and provide the appropriate constant to specify the flip direction.
• The user interface can not be flipped
79. What is the default setting to refer to file locations in your Xcode project?
Answers:
• Relative to Build Product
• Relative to Project
• Relative to Enclosing Group
• Relative to <source path>
• Absolute Path
80. How can you create an OpenGL ES texture with a .png image?
Answers:
• Using UIImage glTexture property
• Using UIImageBitmapRep
• Using CGContextDrawImage in a CGBitmapContext
• You can't
• None of the above
81. By which of the following methods can an NSAutoreleasePool object be created?
Answers:
• autorelease
• alloc
• copy
• retain
82. Is OpenAL available on the iPhone?
Answers:
• Yes
• No
83. What are universal binaries in Xcode?
Answers:
• These are executable files that can contain code and data for more than one architecture.
• These are file references which are generated by the target, such as an application.
• These are indexes that contain symbolic information for your project.
• These are used to specify build location settings.
84. The most effective way to ensure that users have a positive application-switching experience is to _______.
Answers:
• enhance the launch time of the application to the maximum
• reduce the memory space allocated to all applications
• pare the launch time of the application to the minimum
• disable any unused applications
85. Which of the following classes will be used to embbed web content in an iPhone application?
Answers:
• UIWebView
• UIViewController
• UINavigationController
• UITabBarController
86. Are multiple touches enabled by default?
Answers:
• Yes
• No
87. Can your application change the global sound volume?
Answers:
• Yes
• No
88. Which of the following statement is incorrect with regard to Object Ownership in Memory Management?
Answers:
• An object may have one or more owners
• An object is owned by the user if it is created using alloc
• If an object is copied, the retain count is returned as 0
• If an object has no owners, its retain count drops to 0
89. The UIView class provides a function called setAlpha which adjusts the transparency of a view. Which of the following are valid code snippets with regard to setting transparency of a view? It is provided that appView is an object of UIView class.
Answers:
• [ appView setAlpha: 0.5 ];
• [ appView setAlpha: 0.6 ];
• [ appView setAlpha: 1.5 ];
• [ appView setAlpha: 1 ];