Monday, November 7, 2016

iOS Programming Test 2016 – Upwork Test Answers

Upwork iOS Programming Test 2016... 

59 Answered Test Questions:
1. Consider the following code:
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Set Background Color/Pattern
self.window.backgroundColor = [UIColor blackColor];
self.tabBarController.tabBar.backgroundColor = [UIColor clearColor];
//self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@”testbg.png”]];
// Set StatusBar Color
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
// Add the tab bar controller’s current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
How can the error be corrected that gets thrown in the console, “Applications are expected to have a root view controller at the end of application launch”?
Answers:
a. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
a. MenuViewController *menuViewController = [[MenuViewController alloc]init]; self.window.rootViewController = menuViewController; 
a. Both
a. None of above
2. Which of the following allows it to determine if an application is running on iPhone, or if it’s running on an iPod Touch?
Answers:
a. NSString *deviceType = [UIDevice currentDevice].model; if([deviceType isEqualToString:@”iPhone”])
a. NSString *deviceType = [UIDevice currentDevice].Size; if([deviceType isEqualToString:@”iPhone”])
a. NSString *deviceType = [UIDevice currentDevice].device; if([deviceType isEqualToString:@”Device”])
a. NSString *deviceType = [UIDevice currentDevice].iPhone; if([deviceType isEqualToString:@”iPhone”])
3. What is true about ARC and manual memory management?
Answers:
a. Always nil out properties in dealloc under ARC and manual memory management.
a. Do not have to nil out properties in dealloc under ARC and manual memory management.
a. nil out properties in dealloc under ARC but not in manual memory management.
a. nil out properties in dealloc under manual memory management but not in ARC. 
4. What does the “strong” property attribute do?
Answers:
a. It does not extend the lifetime of the object it points to, and automatically becomes nil.
a. It specifies a reference that does not keep the referenced object alive and is not set to nil.
a. It makes the object alive, as long as there is a strong pointer to it. 
a. It specifies a reference that does not keep the referenced object alive and is not set to nil.
5. Which of the following is the best practice to find an active internet connection?
Answers:
a. – (BOOL) connectedToInternet { Reachability *reachability = [Reachability reachabilityForInternetConnection]; NetworkStatus networkStatus = [reachability currentReachabilityStatus]; return !(networkStatus == NotReachable); }
a. – (BOOL) connectedToInternet { NSString *URLString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@”http://www.google.com”]]; return ( URLString != NULL ) ? YES : NO; }
a. – (BOOL) connectedToInternet { NSURL *URLString = [NSURL URLWithString:@”http://www.google.com”]; NSData *data = [NSData dataWithContentsOfURL:URLString]; if (data) return YES; else return NO; }
a. – (BOOL) connectedToInternet { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@”http://www.google.com/”]]; [request setHTTPMethod:@”HEAD”]; NSHTTPURLResponse *response; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error: NULL]; return ([response statusCode] == 200) ? YES : NO; }
6. What gets returned if XIB is not properly connected to a parent controller?
Answers:
a. EXEC_BAD_ACCESS
a. SIGABRT
a. SIGKILL
a. None of these.
7. What is the use of performSelector in iOS?
Answers:
a. To add a class delegate
a. To define a class
a. To call a method of a class
a. To add a selector method
8. Which of the following is the correct way to get the value of the first object of a NsMutableArray stored in another NsMutableArray?
Answers:
a. [[myArray objectAtIndex:0] objectAtIndex:0]; 
a. [myArray objectAtIndex:0]
a. [[[myArray objectAtIndex:0] objectAtIndex:0]objectAtIndex:0];
a. [myArray firstObject]
9. What is the maximum size of an iOS application?
Answers:
a. 20 MB
a. 50 MB
a. 1 GB
a. 2 GB
10. Which of the following is the correct way to set the font size of UIButton title label?
Answers:
a. someButton.font = [UIFont systemFontOfSize: 15];
a. someButton.titleLabel.font = [UIFont systemFontOfSize: 15]; 
a. [someButton setFont: [UIFont systemFontOfSize: 15]];
a. All of the above
11. Which of the following frameworks is needed to apply a border to an object?
Answers:
a. UIKit
a. CoreGraphics
a. QuartzCore
a. Foundation
12. How can it be detected if the app is running on an iPhone 5?
Answers:
a. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone5)
a. if([[UIScreen mainScreen] bounds].size.height == 568) 
a. if([[UIScreen mainScreen] bounds].size.height == 1136)
a. if([[UIDevice currentDevice].model isEqualToString:@”iPhone5″])
13. Which of the following is not a valid Touch method with respect to Cocoa Touch programming?
Answers:
a. – (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
a. – (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
a. – (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
a. None of above
14. Which of the following will return the device’s current location?
Answers:
a. CLLocationManager locationManager = [[CLLocationManager alloc] init]; [locationManager startUpdatingLocation]; 
a. CLLocationManager locationManager = [[CLLocationManager alloc] init]; [locationManager updateLocation];
a. CLLocationManager locationManager = [[CLLocationManager alloc] init]; [locationManager getLocation];
a. CLLocationManager locationManager = [[CLLocationManager alloc] init]; [locationManager findLocation];
15. Which of the following is the correct way to print out stack/trace to the console/log in Cocoa application?
Answers:
a. NSLog(@”%@”,[NSThread callStackSymbols]); 
a. NSLog(@”%@”,[NSThread callStackReturnAddresses ])
a. NSLog(@”%@”,[NSThread currentThread]);
a. None of the above.
16. Which of the following is not a valid UIGestureRecognizer?
Answers:
a. UITapGestureRecognizer
a. UIZoomGestureRecognizer
a. UIRotationGestureRecognizer
a. UIPanGestureRecognizer
17. Which of the following will change the placeholder text color in UITextField?
Answers:
a. textField.placeHolder.textColor = [UIColor redColor];
a. textField.placeHolder.textLabel.textColor = [UIColor redColor];
a. textField.placeHolder.color = [UIColor redColor];
a. None of the above. 
18. Which of the following framework is needed to round corners of UILabel?
Answers:
a. UIKit
a. CoreGraphics
a. QuartzCore
a. CoreAnimation
19. Which of the following is not a valid icon size for any iOS device (iPhone, iPod, iPad)?
Answers:
a. 114 x 114
a. 144 x 144
a. 72 x 72
a. 64 x 64
20. Which of the following is not a valid UIGestureRecognizer?
Answers:
a. UITapGestureRecognizer
a. UIZoomGestureRecognizer
a. UIRotationGestureRecognizer
a. UIPanGestureRecognizer
21. Which of the following will set an image on UIButton?
Answers:
a. button.image = [UIImage imageNamed:@”btn_img.png”];
a. button.imageView.image = [UIImage imageNamed:@”btn_img.png”];
a. [button setImage:[UIImage imageNamed:@”btn_img.png”] forState:UIControlStateNormal]; 
a. [button setImageView:[UIImage imageNamed:@”btn_img.png”] forState:UIControlStateNormal];
22. Select all incorrect bundle ID(s):
Answers:
a. com.company.appName
a. com.appName
a. appName
a. com.company-name.app-name
23. Which of the following will set the font of UISegmentedControl?
Answers:
a. UIFont *font = [UIFont boldSystemFontOfSize:12.0f]; NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:UITextAttributeFont]; [segmentedControl setTitleTextAttributes:attributes forState:UIControlStateNormal]; 
a. [[UISegmentedControl appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@”STHeitiSC-Medium” size:13.0], UITextAttributeFont, nil] forState:UIControlStateNormal];
a. segmentedControl.transform = CGAffineTransformMakeScale(.6f, .6f);
a. None of these.
24. Which of the following correctly sets an image on UIButton?
Answers:
a. button.image = [UIImage imageNamed:@”button_img.png”];
a. button.imageView.image = [UIImage imageNamed:@”button_img.png”];
a. [button setImage:[UIImage imageNamed:@”button_img.png”] forState:UIControlStateNormal]; 
a. [button setImageView:[UIImage imageNamed:@”button_img.png”] forState:UIControlStateNormal];
25. Which of the following font packages are supported by Cocoa-Touch?
Answers:
a. .ttf (True Type Font) 
a. .ttc (True Type font Collection)
a. .otf (Open Type Font)
a. .dFont (MAC OS X Data Fork Font)
26. Which of the following is not an Open Source Framework/Library?
Answers:
a. MBProgressHUD
a. ASIHTTPRequest
a. RestKit
a. StoreKit
27. Which of the following is the best way to add a UIToolbar above keyboard?
Answers:
a. -(void)keyboardWillShow:(NSNotification *)notification { [self.view addSubview:toolbar]; }
a. -(void)textFieldDidBeginEditing:(UITextField *)textField { [self.view addSubview:toolbar]; }
a. Always keep UIToolBar visible on screen.
a. -(void)keyboardWillHide:(NSNotification *)notification { [self.view addSubview:toolbar]; }
28. Select which of the following is not UITableViewCellSelectionStyle values?
Answers:
a. UITableViewCellSelectionStyleNone
a. UITableViewCellSelectionStyleBlue
a. UITableViewCellSelectionStyleLightGray
a. UITableViewCellSelectionStyletGray
29. What is the correct method to define a delegate object in an ARC Environment?
Answers:
a. @property (nonatomic, weak) id delegate; 
a. @property(nonatomic,retain) id delegate;
a. @property(nonatomic,weak) delegate;
a. @property(nonatomic, weak) NSObject *delegate;
30. Which of the following is the best practice to find active internet connection?
Answers:
a. – (BOOL) connectedToInternet { Reachability *reachability = [Reachability reachabilityForInternetConnection]; NetworkStatus networkStatus = [reachability currentReachabilityStatus]; return !(networkStatus == NotReachable); }
a. – (BOOL) connectedToInternet { NSString *URLString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@”http://www.google.com”]]; return ( URLString != NULL ) ? YES : NO; }
a. – (BOOL) connectedToInternet { NSURL *URLString = [NSURL URLWithString:@”http://www.google.com”]; NSData *data = [NSData dataWithContentsOfURL:URLString]; if (data) return YES; else return NO; }
a. – (BOOL) connectedToInternet { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@”http://www.google.com/”]]; [request setHTTPMethod:@”HEAD”]; NSHTTPURLResponse *response; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error: NULL]; return ([response statusCode] == 200) ? YES : NO; }
31. What will be output of following code?
NSLog(@”%.2f”,[[UIDevice currentDevice].systemVersion floatValue]);
Answers:
a. 6.1.0
a. 6.1.2
a. 6.10
a. 6.12
32. What is the difference between new and [[alloc]init] in iOS?
Answers:
a. [[alloc]init] is used to create an object but new is not used to create an object.
a. Neither [[alloc]init] nor new is used for creating an object.
a. No difference. Both [[alloc]init] and new are used to create an object. 
a. [[alloc]init] is not used to create object but new is used to an create object.
33. How can the application name of an iOS project be changed?
Answers:
a. Change Bundle Display Name from info.plist
a. Rename Project
a. Change bundle identifier
a. Create a new project with New name
34. What could be the probable result if selector is unknown or undefined?
Answers:
a. Causes memory leak
a. Causes application to terminate with error
a. Nothing will happen
a. None of above
35. Is it possible to deploy beta build on any device?
Answers:
a. Yes beta build can be deployed on any iOS device.
a. Beta build can be deployed only on devices that are included in Mobile Provision certificate while compiling build. 
a. Beta Build can be deployed only on Simulators.
a. All of above
36. Which one is true regarding integrating and using custom fonts in an iOS application?
Answers:
a. Apple rejects the applications that use custom fonts.
a. Adding fonts to your app plist allows usage directly in the app. 
a. There is no direct way to add fonts; third party APIs are the only way.
a. You can add fonts, but only if they are provided by Apple.
37. Which of the following is the correct way to set UIButton’s Highlight Tint color programmatically?
Answers:
a. [button setColor:[UIColor grayColor]];
a. [button setTintColor:[UIColor grayColor]]; 
a. [button setColor:[UIColor grayColor]];
a. [button TintColor:[UIColor grayColor]];
38. Which of the following properties would be used to draw a shadow under UIView?
Answers:
a. CGContextRestoreShadowState
a. CGContextRestoreGState
a. CGContextSetShadow();
a. CGContextshadowState
39. Which of the following is the correct way to check whether the view controller view is loaded or visible?
Answers:
a. if (viewController.isViewLoaded || tabbarController.view.window) { // viewController is visible }
a. if([[[self tabBarController] selectedViewController] isEqual:self]){ //we’re in the active controller }else{ //we are not }
a. if (viewController.isLoaded && viewController.view.) { // viewController is visible }
a. if (viewController.isViewLoaded && viewController.view.window) { // viewController is visible }
40. Which of the following is the correct way to transfer data from one view controller to another?
Answers:
a. EditingViewController *controller = [[EditingViewController alloc] initWithNibName:@”EditingView” bundle:nil]; controller.editedObject = book; … [self.navigationController pushViewController:controller animated:YES]; [controller release]; In the Editing View (EditingViewController): – (IBAction)save { … [editedObject setValue:datePicker.date forKey:editedFieldKey]; [editedObject setValue:textField.text forKey:editedFieldKey]; } [self.navigationController popViewControllerAnimated:YES]; }
a. NSString *commString; in appDelegate. And then when you submit the uitextfield value just assign that text field value to the appDelegate.commString use this in the next view. ProjectNameAppDelegate *appDelegate = [[UIApplication sharedApplicatoin] delegate]; appDelegate.commString = textField.text;
a. Both 1 and 2 methods are correct. 
a. None of above are correct.
41. Which of the following UILabel properties help adjust text within a UILabel?
Answers:
a. lineBreakMode
a. adjustsFontSizeToFitWidth
a. numberOfLines
a. drawTextInRect:
42. Which of the following is the correct way to set the Navigation Bar Color of the Tab Bar Configure Menu?
Answers:
a. “UINavigationController *navigationController; … navigationController.navigationBar.tintColor = [UIColor blackColor];” 
a. “UINavigationController *navigationController; … navigationController.tintColor = [UIColor blackColor];”
a. “UINavigationController *navigationController; … navigationController.color = [UIColor blackColor];”
a. “UINavigationController *navigationController; … navigationController.navigationBar.Color = [UIColor blackColor];”
43. What does EXC_BAD_ACCESS signal received mean in Xcode?
Answers:
a. Due to warning in code
a. “Owning” the memory but forgetting to release
a. Testing on a device without registering UDID
a. Using incorrect delegate methods
44. Which of the following is best JSON library to be used in iOS applications?
Answers:
a. SBJSON
a. JSON kit
a. Touch JSON
a. None of these
45. How can an SMS be sent programmatically from the iPhone (iOS 4.0 or later)?
Answers:
a. Using MFMessageComposeViewController
a. [[UIApplication sharedApplication] openURL: @”sms:PHONE-NUMBER”];
a. Both A &B are correct answers
a. The official SDK/Cocoa Touch doesn’t allow sending SMSs programmatically
46. What is the difference between assign and retain in Objective-C?
Answers:
a. assign – Specifies that a copy of the object should be used for assignment. The previous value is sent a release message. retain – Specifies that the setter uses simple assignment. The previous value is sent a release message.
a. assign – Specifies that the setter uses simple assignment. This is the default. retain – Specifies that retain should be invoked on the object upon assignment. The previous value is sent a release message. 
a. assign – Increases the count of an object by 1. Takes ownership of an object. retain – Decreases the retain count of an object by 1. Relinquishes ownership of an object.
a. assign – Makes a assign of an object, and returns it with retain count of 1. If you copy an object, you own the copy. retain – Specifies that a retain of the object should be used for assignment. The previous value is sent a release message.
47. Which property would be used to get the UDID of UIDevice on iOS?
Answers:
a. [UIDevice UDIDString]
a. [UIDevice uniqueIdentifier] 
a. -[UIDevice identifierForVendor]
a. None of these
48. When does this behavior usually happen?
“Xcode Message: finished running ” on targeted device shows, but nothing happens
Answers:
a. If the app was ran on earlier devices (3G or 3GS) and arm6 was not added in Require Device Capabilities. 
a. If app was built and ran on version 3.2 or earlier of Xcode and arm7 was not added in Require Device Capabilities.
a. If Bundle Identifier used in the project is being used by another project
a. When some another application is already running on device
a. When the device is locked with a passcode
49. Is it possible to set multiple architecture from Build Settings tab in Xcode for a project?
Answers:
a. Yes
a. No
a. only in Xcode 4.5 or later
a. only in Xcode 4.5 or previous
50. Which framework can be used to call SOAP web services in iOS applications?
Answers:
a. gSOAP
a. ASIHTTP framework
a. wsdl2objc framework
a. None of these
51. What property in info.plist handles the association of file types in an iPhone application?
Answers:
a. LSItemContentTypes
a. LSHandlerRank
a. CFBundleTypeName
a. CFBundleTypeRole
52. Which method of Objective-C handles detecting the shake gesture on an iOS device?
Answers:
a. + (UIAccelerometer *)sharedAccelerometer
a. – (void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
a. – (void) accelerometer:(UIAccelerometer *)accelerometer willAccelerate:(UIAcceleration *)acceleration
a. – (void) accelerometer:(UIAccelerometer *)accelerometer beginAccelerate:(UIAcceleration *)acceleration
53. Which one is the best resolution for the following error?
“A valid signing identity matching this profile could not be found in your keychain”
Answers:
a. Installing the certificate file in your keychain
a. Renewing your provisioning profile
a. Installing the private key in your keychain
a. Renewing your Apple developer account.
54. What is the best way to show multiple lines text in the UILabel?
Answers:
a. CGRect currentFrame = myLabel.frame; CGSize max = CGSizeMake(myLabel.frame.size.width, 500); label.font = [UIFont systemFontOfSize:13.0]; CGSize expected = [myString sizeWithFont:myLabel.font]; myLabel.numberOfLines = 0;
a. CGRect currentFrame = myLabel.frame; CGSize max = CGSizeMake(myLabel.frame.size.width, -1); CGSize expected = [myString sizeWithFont:myLabel.font]; myLabel.numberOfLines = -1;
a. myLabel.numberOfLines = 0; CGRect currentFrame = myLabel.frame; CGSize max = CGSizeMake(myLabel.frame.size.width, 500); CGSize expected = [myString sizeWithFont:myLabel.font constrainedToSize:max lineBreakMode:myLabel.lineBreakMode]; currentFrame.size.height = expected.height; myLabel.frame = currentFrame; 
a. You have to use UITextView for this purpose, otherwise Apple will rejects your app submission
55. Which of the following correctly describes when the – (void)viewDidUnload method is called?
Answers:
a. When the application launches.
a. When any view appears.
a. When a view is released. 
a. During low memory conditions when the view controller needs to release its view.
56. Which of the following is not a valid MKAnnotationView property?
Answers:
a. canShowCallout
a. draggable
a. dragState
a. None of these. 
57. What does a “__block” type specifier mean?
Answers:
a. Modifications made with the variable marked with __block inside the block are not visible outside of it.
a. Modifications done with the variable marked with __block inside the block are also visible outside of it. 
a. It makes the variable non-mutable within the block.
a. None of the above
58. Which of the following is not a valid MPVolumeView method?
Answers:
a. – (CGRect)volumeThumbRectForBounds:(CGRect)bounds volumeSliderRect:(CGRect)rect value:(float)value
a. – (UIImage *)maximumVolumeSliderImageForState:(UIControlState)state
a. – (CGRect)routeButtonRectForBounds:(CGRect)bounds
a. – (void)setVolumeThumbImage:(UIImage *)image
59. Which of the following code samples will declare a variable inside a block in Objective-C?
Answers:
a. Person *aPerson = nil; [participants enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { Person *participant = (Person*)obj; if ([participant.gender isEqualToString:@”M”]) { aPerson = participant; *stop = YES; } }]; return aPerson;
a. __block Person *aPerson = nil; [participants enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { Person *participant = (Person*)obj; if ([participant.gender isEqualToString:@”M”]) { aPerson = participant; *stop = YES; } }]; return aPerson;
a. [participants enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { Person *participant = (Person*)obj; Person *aPerson = nil; if ([participant.gender isEqualToString:@”M”]) { aPerson = participant; *stop = YES; } }]; return aPerson;

No comments:

Post a Comment

Earn for Free

http://hiredrmjru.trade/3670784521590/