In this post you can find Complete and recently updated Correct Question and answers of Objective C. All Answers updated regularly with new questions. Upwork Objective C test answers of 2016.
Question:* What is a pointer?
Answer: • A memory address that points to a specific object
Question:* What is the difference between #import and #include ?
Answer: • #import ensures that a file is only ever included once, and #include allows the same file to be inlcuded many times.
Question:* How do you get the Unicode character set of a Core Text font?
Answer: • CTFontCopyCharacterSet
Question:* What is the method for adding KVO to your app?
Answer: • addObserver:forKeyPath:options:context
Question:* How can you declare a method, that can be set as the action to be performed on various events?
Answer: • - (IBAction) action:(id) sender;
Question:* What is a design pattern?
Answer: • A template for a solution to a common problem faced by programmers.
Question:* True or False? For an object to use constraints, it must have at least 3 constraint values.
Answer: • False
Question:* Does Objective-C have constructors and destructors?
Answer: • No, you use init and dealloc on Objective-C
Question:* What framework is KVO (key value observing) a part of?
Answer: • Foundation
Question:* If you do not declare a return type for a method definition, what is the default return type?
Answer: • id
Question:* What class supports the sharing of small amounts of data such as strings or dates to iCloud?
Answer: • NSUbiquitousKeyValueStore
Question:* Assume ARC is enabled... What would be another way to write this: NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @"Three",nil];
Answer: • NSArray *array = @[@"One", @"Two", @"Three"];
Question:* What is the type of @selector(foo)?
Answer: • SEL
Question:* Using UIViewController containment, which one of the following statements is true:
Answer: • The root viewcontroller handles loading and unloading its child viewcontrollers.
Question:* what does this code produce? [NSString] *myString = @"Hello World";
Answer: • An Error during compile
Question:* Can you call C++ code from objective C environment?
Answer: • Yes, from any .mm file
Question:* What is a dependency in NSOperationQueue?
Answer: • A dependency is a way to have an operation wait to be performed until the dependencies have been fulfilled/executed
Question:* If a class conforms to a protocol what must it do?
Answer: • Implement all methods in the protocol, except for optional ones
Question:* Which of the following accesses a variable in structure b?
Answer: • b.var;
Question:* How can you add a new method foo to an existing class Bar?
Answer: • Make a category, e.g. @interface Bar(Foo).
Question:* 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.
Answer: • False
Question:* What is KVO?
Answer: • Key Value Observing
Question:* What is a Category?
Answer: • A category is a way to extend a class by adding functions to it
Question:* True or False? A method and a variable can have the same name in Objective-C.
Answer: • True
Question:* How does KVO respond to change notifications?
Answer: • observeValueForKeyPath:ofObject:change:context
Question:* What is the Allocations instrument used for?
Answer: • Recording information from a single process about memory allocation
Question:* What is used to sort Core Data results?
Answer: • NSSortDescriptor
Question:* True or False? You can compare two strings by (string1 == string2)
Answer: • False
Question:* What is the difference between methods that begin with + and -?
Answer: • Instance methods begin with - class level methods begin with +
Question:* What does a CAEmitterCell do?
Answer: • It defines the properties and direction of emitted particles from a CAEmitterLayer object.
Question:* What happens when you call retain on an object?
Answer: • You increase its retain count by 1
Question:* What type of object is this under XCode 4.5: @[rabbit, chicken, owl]
Answer: • NSArray
Question:* How do you free an object?
Answer: • [obj release]
Question:* True or False? A UIButton inherits from UIView.
Answer: • True
Question:* What does the "id" type mean?
Answer: • This is the general type for any kind of object regardless of class
Question:* Which of the following is a Singleton?
Answer: • [NSFileManager defaultManager]
Question:* How do you concatenate two NSStrings *foo and NSString *bar to form a new NSString *baz?
Answer: • baz = [foo stringByAppendingString: bar];
Question:* What framework does the class UIButton come from?
Answer: • UIKit
Question:* Are integers full-fledged objects in Objective-C?
Answer: • No, they are not objects at all.
Question:* What does an Objective-C string literal look like?
Answer: • @"foo"
Question:* If you define a new class called Foo which inherits from NSObject, how do you create a new instance of it?
Answer: • Foo *temp = [[Foo alloc] init];
Question:* ARC means?
Answer: • Artificial Reference Counting
Question:* Where is a MKAnnotationView used?
Answer: • On a Map View
Question:* What is a delegate?
Answer: • A delegate allows one NSObject to send messages to another NSObject, and listen to those messages
Question:* What is the name of the type of SQL Database that iOS Supports?
Answer: • SQLite
Question:* What is one source of particles that are emitted by a CAEmitterLayer object?
Answer: • A CAEmitterCell
Question:* In Core Data, what is the name of an object representation of a record?
Answer: • NSManagedObject
Question:* True or False? You should use NSHost when connecting to a specific host.
Answer: • False (You should use CFHost)
Question:* What happens at runtime with the following: NSObject* object = nil; NSObject* object2 = [object copy]; NSLog(@"%@", object2);
Answer: • Log prints "(null)" and continues as usual.
Question:* True or False? You can perform operator overloading in Objective-C.
Answer: • False
Question:* True or False? Strings are one of the most common sources of buffer overflow attacks.
Answer: • True
Question:* What class will allow you to use one or more blocks concurrently?
Answer: • NSBlockOperation
Question:* What is the 'print object' command in the debugger window?
Answer: • po
Question:* The proper typedef syntax for an Objective-C block that takes an NSArray and returns an NSString is
Answer: • typedef NSString *(^aBlock)(NSArray *);
Question:* What is a persistent object store?
Answer: • It represents an external file of persisted data
Question:* What is the difference between [Foo new] and [[Foo alloc] init]?
Answer: • None, they perform the same actions.
Question:* What is a proper format for calling an asynchronous function?
Answer: • dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ // code });
Question:* What are the two types of predicates?
Answer: • Comparison and Compound
Question:* What is Objective-C's language design based on?
Answer: • C and Smalltalk.
Question:* True or False? You can use %@ to specify a dynamic property.
Answer: • False
Question:* How do you convert a Core Image color to a UIColor?
Answer: • colorWithCIColor:
Question:* In Core Data, what is the name of the object representation for the database schema?
Answer: • NSManagedObjectModel
Question:* What can happen if you use self inside a block?
Answer: • You can create a retain cycle
Question:* 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:
Answer: • instancetype
Question:* True or False? The format for a NSPredicate is the same as a Regular Expression.
Answer: • False
Question:* What protocol is used to create an action object?
Answer: • CAAction
Question:* What is the object.toString equivalent in objective-c?
Answer: • [NSObject description]
Question:* How can you temporarily disable layer actions in a Core Animation?
Answer: • Using the CATransaction class
Question:* What class method is used to make an NSArray from NSData class?
Answer: • NSKeyedUnarchiver unarchiveObjectWithData:
Question:* What is (void*)0 ?
Answer: • Representation of NULL pointer
Question:* Which of these property declaration attributes does not specify setter semantics?
Answer: • nonatomic
Question:* Which of these classes is NOT a root class?
Answer: • NSString
Question:* What does the following code do, assume ARC is enabled? NSArray *myArray; for (int i = 0; i < 10; i++){ @autoreleasepool { myArray = [[NSArray alloc]init]; } }
Answer: • For each iteration of the loop a new array is allocated and released.
Question:* True or False? Key value coding is used to indirectly access an object's attributes using indexes.
Answer: • False
Question:* If you wanted to override the default alloc method in a class Foo, what would be the appropriate way to declare it?
Answer: • + (id) alloc;
Question:* What do you use for an outgoing TCP connection?
Answer: • NSStream
Question:* What happens if you use fgets and do not give it a size smaller than the buffer?
Answer: • It will overwrite the data past the size
Question:* What can you say about the code: NSString * str = [NSString stringWithFormat:@""]; [str release];
Answer: • It will cause the string to be released twice with undefined consequences when the surrounding autorelease pool is emptied
Question:* How do you add a brightening effect on a CoreImage?
Answer: • CIAdditionCompositing
Question:* Which method, if defined, is guaranteed to be called once -- and only once -- when a class is first referenced?
Answer: • + (void) initialize;
Question:* Which of these methods is NOT invoked by the runtime itself?
Answer: • -dealloc
Question:* What is the last chance for an object to handle a message?
Answer: • -forwardInvocation:
Question:* How is a selector typically represented in memory?
Answer: • As a null terminated C string.
No comments:
Post a Comment