
objective c linkedin assessment answers
1. What is the initial value of the property val?
@property (nonatomic, readonly) int val;
- nill
- 0
- undefined
- -1
2. What is the difference between an array and a set?
- Arrays are ordered, non-unique values.
- Sets can contain nils.
- Arrays are stored sorted.
- Sets are ordered, unique values.
3. What is foo?
- (float)foo;
- This code contains an error.
- a variable declaration of type float
- a function with a return type of float
- a property of type float
4. What are categories used for?
- to extend other classes
- to manage access control
- to coordinate objects
- to group classes
5. What is wrong with this code?
@interface MyClass : Nsobject
@property (strong, nonatomic, readonly) NSString
*name;
@end
- There is no read-onlv directive.
- MyClass does not implement NSObject.
- There is nothing wrong with this code.
- Properties are declared in the implementation.
6. What is printed from this code?
NSData *data = (@"print"
dataUsingEncoding:NSASCIIStringEncoding];
NSLog(@"%.@"
, [[NSString alloc] initWithData:data
encoding: NSASCIIStringEncoding]);
- Nothing is printed from this code.
- This code is invalid.
- <nil>
7. What is wrong with this code?
NSDictionary *d1 = @[@"vl", @4, @"v2", @5.6, @"v3"] ;
NSLog (@"d1: %@", d1) ;
- Dictionaries cannot have mixed types as values.
- d1 is assigned an NSArray of values.
- The last key is missing a value.
- NSDictionaries cannot be printed this way.
8. What is the value of result after this code is executed?
NSStrina *result = [@"test
stringByTrimmingCharactersInset:NSCharacterSet
โขalphanumericCharacterSet];
- none of these answers
- โesโ
- โtestโ
- โ โ
9. What does this expression evaluate?
a=b?:c;
- a equals b when b and c are both comparable types.
- a equals b when c is nil; otherwise a equals c.
- a equals b if b is not nil: otherwise a equals c.
- a equals b subscripted by c.
10. What is printed from this code execution?
typedef enum {
thing1,
thing2,
thing3
} Thing;
- (void) enumstuff {
NSLog(@"%d", thing2) ;
}
- 0
- This code does not print anything.
- 1
- thing2
11. What is significant about this function declaration?
- (void) testFunc: (NSString**)str;
- The parameter is passed by value and can not be changed.
- ** is not allowed on a parameter.
- The parameter is passed by reference and may be changed
- The parameter may be nil.
12. Dot notation can be used for _____.
- nothing, as it is never used in Objective-C
- property getter/setter
- parameter delimiters
- function calls only
14. What does this code print?
NSArray *vals = @[@"1", @"2", @"3"] ;
[vals makeObjectsPerformSelector: @selector (NSLog) ] ;
- @โ1โณ @โ2โณ @โ3โณ
- โ1โ, โ2โ, โ3โ
- 123
- Nothing, since this code contains an error.
15. You want to store a small amount of information, such as user settings What is the best, built-in way to go?
- plist file
- text file
- CoreData
- UserDefaults