Practice Question: What is a pointer?

A memory address that points to a specific object

 

What is the type of @selector(foo)?

SEL

 

What is the difference between [Foo new] and [[Foo alloc] init]?

None, they perform the same actions.

 

Assume ARC is enabled… What would be another way to write this: NSArray *array = [NSArray arrayWithObjects:@”One”, ©”Two”, @”Threen,nil];

NSArray ‘array = ©[©”One”, ©”Two”, ©”Three”];

 

Name the core interface framework which is used in iOS development.

UIKit

 

what does this code produce? [NSString] *myString = @”Hello World”;

An Error during compile

 

What framework is KVO (key value observing) a part of?

Foundation

 

What is the difference between #import and #include ?

#import ensures that a file is only ever included once, and #include allows the same file to be inlcuded many times.

 

Are integers full-fledged objects in Objective-C?

No, they are not objects at all.

 

Yes, but only if you first cast them as id’s, e.g. (id) 123.

Yes.

 

True or False? A method and a variable can have the same name in Objective-C.

True

 

What is one source of particles that are emitted by a CAEmitterLayer object?

A CAEmitterCell

 

True or False? For an object to use constraints, it must have at least 3 constraint values.

False

 

In Core Data, what is the name of an object representation of a record?

NSManagedObject

 

What class supports the sharing of small amounts of data such as strings or dates to iCIoud?

NSUbiquitousKeyValueStore

 

What class will allow you to use one or more blocks concurrently?

NSBIockOperation

 

What is Objective-C’s language design based on?

C and Smalltalk.

 

What happens at runtime with the following: NSObject* object = nil; NSObject* object2 = [object copy]; NSLog(@”%@,,I object2);

Log prints “(null)” and continues as usual.

 

What is a proper format for calling an asynchronous function?

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND 0), A{ // code });

 

The proper typedef syntax for an Objective-C block that takes an NSArray and returns an NSString is

typedef NSString *(AaBlock)(NSArray *);

 

What is the ‘print object’ command in the debugger window?

Answer: po

 

What can happen if you use self inside a block?

You can create a retain cycle

 

If you do not declare a return type for a method definition, what is the default return type?

Answer: id

 

What is the object.toString equivalent is objective-c?

[NSObject description]

 

How do you convert a Core Image color to a UlColor?

colorWithCiColor:

 

What is (void*)0 ?

Representation of NULL pointer

 

Using UlViewController containment, which one of the following statements is true:

The root viewcontroller handles loading and unloading its child viewcontrollers.

 

What are the two types of predicates?

Comparison and Compound

 

What does the following code do, assume ARC is enabled? NSArray *myArray; for (int i = 0; i < 10; i++X @autoreleasepool { myArray = [[NSArray alloc]init]; }}

For each iteration of the loop a new array is allocated and released.

 

Which of these classes is NOT a root class?

NSString

 

In Core Data, what is the name of the object representation for the database schema?

NSManagedObjectModel

 

True or False? Strings are one of the most common sources of buffer overflow attacks.

True

 

True or False? You can use %@ to specify a dynamic property.

False

 

What can you say about the code: NSString * str = [NSString stringWithFormat:@””]; [str release];

It will cause the string to be released twice with undefined consequences when the surrounding autorelease pool is emptied

 

Which of these property declaration attributes does not specify setter semantics?

nonatomic

 

If you wanted to override the default alloc method in a class Foo, what would be the appropriate way to declare it?

+ (id) alloc;

 

True or False? You can perform operator overloading in Objective-C.

False

 

What protocol is used to create an action object?

CAAction

 

True or False? You should use NSHost when connecting to a specific host.

False (You should use CFHost)

 

Objective-C methods with certain names (“init”, “alloc”, etc.) always return objects that are an instance of the receiving class’s type; such methods are said to have a “related result type”. A method with a related result type can be declared by using:

instancetype

 

What class method is used to make an NSArray from NSData class?

NSKeyedUnarchiver unarchiveObjectWithData:

 

True or False? The format for a NSPredicate is the same as a Regular Expression.

False

 

How do you add a brightening effect on a Corelmage?

ClAdditionCompositing

 

Which method, if defined, is guaranteed to be called once — and only once — when a class is first referenced?

+ (void) initialize;

 

What do you use for an outgoing TCP connection?

NSStream

 

What is the last chance for an object to handle a message?

-forward Invocation:

 

What is the export format for the Carbon Events Instrument?

A DTrace Script

 

What kind of socket does a CFSocket use?

A BSD Socket

 

True or False? Key value coding is used to indirectly access an object’s attributes using indexes.

False

 

How can you declare a method, that can be set as the action to be performed on various events?

– (IBAction) action:(id) sender;

 

True or False? Sending a command asynchronously will lock the main thread and then wait until the command is finished before moving on to the next part of your code.

False

 

Does Objective-C have constructors and destructors?

No, you use init and dealloc on Objective-C

 

What is used to sort Core Data results?

NSSortDescriptor

 

If a class conforms to a protocol what must it do?

Implement all methods in the protocol, except for optional ones

 

What is a Category?

A category is a way to extend a class by adding functions to it

 

Can you call C++ code from objective C environment?

Yes, from any .mm file

 

How can you add a new method too to an existing class Bar?

Make a category, e.g. @interface Bar(Foo).

 

Which of these methods is NOT invoked by the runtime itself?

-dealloc

 

What is a dependency in NSOperationQueue?

A dependency is a way to have an operation wait to be performed until the dependencies have been fulfilled/executed

 

Which of the following accesses a variable in structure b?

b.var;

 

What is the Allocations instrument used for?

Recording information from a single process about memory allocation

 

How does KVO respond to change notifications?

observeValueForKeyPath:ofObject:change:context

 

True or False? You can compare two strings by (string1 == string2)

False

 

How is a selector typically represented in memory?

As a null terminated C string.

 

What is KVO?

Key Value Observing

 

How do you get the Unicode character set of a Core Text font?

CTFontCopyCharacterSet

 

Storyboards were introduced with which version of iOS?

Answer: 5.0

 

True or False? A UIButton inherits from UlView.

True

 

What is the function that determines what is in the cells of a tableView?

cellForRowAtlndexPath

 

What type of object is this under XCode 4.5: @[rabbit, chicken, owl]

NSArray

 

What is the difference between methods that begin with + and -?

Instance methods begin with – class level methods begin with +

 

What is the method for adding KVO to your app?

addObserver:forKeyPath:options:context

 

What happens when you call retain on an object?

You increase its retain count by 1

 

Which of the following is a Singleton?

[NSFileManager defaultManager]

 

What does the “id” type mean?

This is the general type for any kind of object regardless of class

 

What does a CAEmitterCell do?

It defines the properties and direction of emitted particles from a CAEmitterLayer object.

 

How do you concatenate two NSStrings *foo and NSString *bar to form a new NSString *baz?

baz = [foo stringByAppendingString: bar];

 

What framework does the class UIButton come from?

UIKit

 

What does an Objective-C string literal look like?

@”foo”

 

If you define a new class called Foo which inherits from NSObject, how do you create a new instance of it?

Foo *temp = [[Foo alloc] init];

 

Where is a MKAnnotationView used?

On a Map View

 

ARC means?

Automatic Reference Counting

 

What is a delegate?

A delegate allows one NSObject to send messages to another NSObject, and listen to those messages

 

What is the name of the type of SQL Database that iOS Supports?

SQLite

 

Objective C is the main programming language for which platform?

Answer: iOS

Objective-C Test Questions and Answers

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *

Этот сайт использует Akismet для борьбы со спамом. Узнайте как обрабатываются ваши данные комментариев.