Objective-C Test

Exam Type: Objective-C MCQ Skill Test
Questions Type: Multiple Choice Questions
Total Questions: 32
Time Limit: 30 Minutes
Last Update June, 2025

Pass Objective-C Exam

75%
Total time

1 minute 2 seconds

Total time

1 correct answers

Total time

6 incorrect answers

Total time

6 not attempted

Start

Objective-C Quiz

Question 1 of 32
30:00

What is the value of s?
NSMutableString *s = [NSMutableString stringWithString:@"123"];
 [s appendString:@"456"];

  • 123
  • 123456
  • 456
  • This code contains an error.
     

What's the value of i after these statements?
NSString *str = nil;
NSInteger i = str.integerValue;

  • This code crashes.
  • nil
  • -1
  • 0
     

What value is in str after this line is executed?
NSString str = "test" + " " + "more";

  • test
  • nil
  • This code contains an error.
  • test more
     

What does this code print?
NSPredicate *p2 = [NSPredicate predicateWithBlock:^BOOL(NSString* evaluatedObject,
 NSDictionary<NSString *,id> * _Nullable bindings) {
 return evaluatedObject.intValue % 2 == 0;
}];

NSArray *vals = @[@"1",@"2",@"3"];
NSArray *n2 = [vals filteredArrayUsingPredicate:p2];
NSLog(@"%@", n2.firstObject);

  • Nothing, since this code contains an error.
  • 1,2
  • 2
  • 1,2,3
     

What is foo?
-(float)foo;

  • A property of type float.
  • A variable declaration of type float.
  • A function with a return type of float.
  • This code contains an error.
     

What can you glean from this line?
#import "NSString+NameHelper.h"

  • NSString implements the NameHelper protocol.
  • NameHelper is a subclass of NSString.
  • NameHelper is a category for NSString.
  • NSString has a helper class.
     

What's wrong with this code?
float x = 5.;

  • Nothing is wrong with this code.
  • Declarations do not need semicolons.
  • x=5 is an invalid float.
  • Variables can't be declared and initialized in the same statement.
     

How many times with this loop be executed?
for (int x=0; x<100; x++) {
 x = x + 1;
}

  • 50
  • This code contains an error.
  • 100
  • 99
     

What is printed for this code?
int val = 0;
 val = 1.5;
 printf ("%d", val);

  • 2
  • This code contains an error.
  • 1
  • 0
     

How many keys does this NSDictionary have after this code is executed?
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:
  @"b",@"e",@"a",@"r", nil];

  • 4
  • This code contains an error.
  • 2
  • 5
     

What is wrong with this code?
NSMutableDictionary *dict1 = [NSMutableDictionary dictionaryWithCapacity:5];
[dict1 setValue:@"key" forKey:@"value"];

  • The key and value items are mixed.
  • You can't set the capacity on a dictionary.
  • NSMutableDictionary doesn't have a :setValue:forKey function.
  • Nothing is wrong with it.
     

What is printed from this code?
NSData *data = [@"print" dataUsingEncoding:NSASCIIStringEncoding];
NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);

  • <nil>
  • This code is invalid.
  • print
  • Nothing is printed from this code.
     

What is different about this function?
+(void)doSomething;

  • It is inline.
  • It is static.
  • It is abstract.
  • This code contains an error.
     

What's wrong with this code?
@interface MyClass : NSObject
        @property (strong,nonatomic, readonly) NSString *name;
    @end

  • There is no read-only directive.
  • MyClass doesn't implement NSObject.
  • Properties are declared in the implementation.
  • There is nothing wrong with this code.
     

What is the value of newVals after this code is executed?
NSArray *vals = @[@"1",@"2",@"3"];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF.intValue > 1"];
NSArray *newVals = [vals filteredArrayUsingPredicate:pred];

  • 2,"3"
  • This code contains an error.
  • nil
  • 2,3
     

What is an enums base type for the code below?
typedef enum { Foo1, Foo2 } Foo;

  • There is no base type.
  • int
  • NSNumber
  • NSObject
     

What is this Objective-C code checking?
if ([keyPath isInstanceOf:[NSString class]]) {
}

  • if keyPath is an instance of NSString
  • This code contains an error.
  • if keyPath's baseclass is the same as NSString's baseclass
  • if keyPath implements the same methods as NSString
     

For observing changes to a property, which of these two statements causes the related method to be called and why?
1. _val = 1;
2. self.val= 100;

  • Statement 1, since it uses the property directly.
  • Statement 2, since it calls the auto-created setter on the property.
  • Statement 1, since it calls the auto-created setter on the property.
  • Statement 2, since it specifies the class instance to use.
     

What's wrong with this code?
float x = 2.0;
int (^foo)(int) = ^(int n1){
 return (int)(n1*x);
};
foo(5);

  • x is not in the right scope.
  • Nothing is wrong with this code.
  • Ints and floats can't be multiplied.
  • The parameter isn't declared correctly.
     

How would this function be called?
-(int)foo:(int)a b:(int)c;

  • self.foo(5, b:10);
  • This code contains an error.
  • [self foo:5:10:20];
  • [self foo:5 b:10];
     

What is this a declaration of?
int(^foo)(int);

  • a block of code
  • a Generic
  • an abstract class
  • an Extension
     

What's wrong with this line of code?
int temp = 1==1;

  • temp is a keyword.
  • 1==1 is invalid.
  • 1==1 evaluates to a boolean.
  • Nothing is wrong with it.
     

Property defaults include _____.?

What is the key difference between NSDictionary and NSMutableDictionary?

What does ARC stand for?

What best describes class inheritance in Objective-C?

Structs can have _____.?

You want to store a small amount of information, such as user settings. What is the best, built-in way to go?

What are categories used for?

What's the difference between an array and a set?

Dot notation can be used for _____.?

What is the purpose of declaring a method Header file?

Objective-C Test Explained

© 2025 Skill Test Answer. All Rights Reserved