Objective-C Quiz
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 80% Most missed: “What is wrong with this code?”

Objective-C MCQs For LinkedIn Skill Assessments.

Objective-C Quiz
Time left 00:00
25 Questions

1. How many items are in set1 after this code executes?

NSMutableSet *set1 = [NSMutableSet setWithObjects: @1,@2, @3, @4, @5, nil];
[set1 add0bject:@3];
2. What is an enums base type for the code below?
'typedef enum { Foo1, Foo2} Foo;'
3. What is foo?
'-(float)foo;'
4. Property defaults include \_?
5. Dot notation can be used for \_?
6. What is significant about this function declaration?
-(void)testFunc:(NSString')str;
7. What is this code an example of?
'[self addObserver: self forKeyPath: @'val' options:0 context: nil];'
8. What does this code print?

NSPredicate *p2 = [NSPredicate predicateWithBlock:^BOOL(NSString* evaluatedObject, NSDictionary * _Nullable bindings) {
return evaluatedObject.intValue % 2 == 0;
}];
NSArray *vals = @[@'1', @'2', @'3'];
NSArray *n2 = [vals filteredArrayUsingPredicate:p2];
NSLog(@'%@', n2.firstObject);
9. What is printed for this code?

int val = 0;
val = 1.5;
printf('%d', val);
10. Structs can have \_?
11. For observing changes to a property, which of these two statements cause the related method to be called and why?

1. _val = 1;
2. self.val= 100;
12. What best describes class inheritance in Objective-C?
13. What is this Objective-C code checking?

if ([keyPath isInstanceOf:[NSString class]]) {
}
14. What is the key difference between NSDictionary and NSMutableDictionary?
15. What is wrong with this code?

NSDictionary *d1 = @[@'v1', @4, @'v2', @5.6, @'v3'];
NSlog(@'d1: %@', d1);
16. You are worried about threaded access to a property and possible collision in writing. What directive should you use on the property?
17. How many keys does this NSDictionary have after this code is executed?
'NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: @'b', @'e', @'a', @'r', nil];'
18. What is special about the code within this block?

dispatch_async(dispatch_get_main_queue(), ^{
// code
});
19. What are categories used for?
20. What's the value of i after these statements?

NSString *str = nil;
NSInteger i = str.integerValue;
21. What is different about this function?
'+(void)doSomething;'
22. What is this a declaration of?
'int(^foo)(int);'
23. What value is in str after this line in executed?
'NSString str = 'test' + ' ' + 'more';'
24. What is wrong with this code?

float x = 2.0;
int(^foo)(int) = ^(int n1) {
return (int)(n1*x);
};
foo(5);
25. How would this function be called?
'-(int)foo:(int)a b:(int)c;'