Хотите пройти тесты на Upwork, но не хотите тратить свое время?
Подавайте заявку и мы пройдем тесты на Upwork вместо Вас!

Do You want to pass tests on Upwork but not want to waste Your time?
Leave the request and we will pass tests on Upwork instead of You!

Objective-C Test 2017

Share on RedditPin on PinterestEmail this to someoneShare on TumblrShare on LinkedInShare on Google+Tweet about this on TwitterShare on FacebookShare on VK

Мы не гарантируем правильность всех предоставленных ответов.
Возможно, с данными ответами Вы сможете пройти тест на TOP-30.
Подавайте заявку и мы пройдем этот тест на оценку TOP-20 вместо Вас!


59 Test Questions:

1. What is a category?

Answers:

• A namespace
• A category is a way to add instance variables to a class which already exists
• A category is a group of classes
• A category is a way to add methods to a class which already exists
• None of the above

2. Is the following code a correct allocation?

MyClass myObj;
[&myObj aMessage];

Answers:

• Yes
• No

3. What is the default visibility for instance variables?

Answers:

• @private
• @package
• @public
• @protected
• None of the above

4. Which of the following creates a class that conforms to a protocol?

Answers:

• @interface ClassName [ProtocolName]
• @interface ClassName <ProtocolName>
• @interface ClassName < ProtocolName
• @interface ClassName::ProtocolName
• @interface ClassName(ProtocolName)

5. What is nil?

Answers:

• The null object
• The null class
• It doesn’t exist
• None of the above

6. What is not supported in Obj-C?

Answers:

• Recursive method call
• Variable argument count to method
• Byte manipulation
• Method argument default value
• None of the above

7. What class specifiers are supported?

Answers:

• FINAL
• STATIC
• FAST
• ITERATIVE
• There is no such thing as class specifiers

8. Which of the following is false?

Answers:

• Method lookup is done at runtime
• When a method is called, the send is automatically available as the sender variable, like self or super
• Messages can be sent to nil
• Methods in static libraries must be present at link time

9. What is the Obj-C runtime?

Answers:

• A C library
• A compiler
• A language
• A dynamic loader

10. What can be linked to an Obj-C program without any particular process?

Answers:

• C libraries
• Java jar files
• C++ libraries
• scripts
• Executables

11. Which of the following declares a protocol?

Answers:

• @proto ProtocolName
• protocol ProtocolName {};
• @protocol ProtocolName
• @interface <ProtocolName>
• @interface ProtocolName::Protocol

12. What is an IMP?

Answers:

• A special type used for computation
• An alias for SEL
• A preprocessor directive defined to the implementation name
• The C type of a method implementation pointer
• None of the above

13. How do you allocate an object?

Answers:

• MyClass *obj = malloc(sizeof(MyClass));
• MyClass *obj = [MyClass alloc];
• MyClass *obj = alloc(MyClass);
• MyClass *obj = [MyClass new];
• None of the above

14. What is a protocol?

Answers:

• A class that uses functions instead of methods
• A method signature
• A class signature
• An interface without an implementation
• None of the above

15. What will be the output of the following code?

static int
a (void)
{
printf («a\n»);
return 0;
}

static int
b (void)
{
printf («b\n»);
return 1;
}

static int
c (void)
{
printf («c\n»);
return 2;
}

int
main (int argc, const char *argv[])
{
printf («%d %d %d», a (), b (), c ());
return 0;
}

Answers:

• a b c 0 1 2
• a b c 2 1 0
• c b a 0 1 2
• c b a 2 1 0
• None of the above

16. What does Obj-C not support?

Answers:

• Instance variables
• Class variables
• Static variables
• Automatic variables

17. What does the following imply?

Worker *ceo = [[Worker alloc] init];
ceo->boss = nil;

Answers:

• That the ceo object is statically typed
• That the boss instance variable is declared @protected
• That the boss instance variable is declared @public
• That the ceo is in fact a structure
• This code is not correct

18. What can you do with categories?

Answers:

• Add instance variables to a class without subclassing it
• Add methods to a class without subclassing it
• Override methods of a class without subclassing it
• None of the above

19. What comments are supported in Obj-C?

Answers:

• // Line comments
• /* Block comments */
• # Line comments
• ; Line comments
• -[[ block comments ]]

20. What is true regarding C functions inside .m files?

Answers:

• They can contain Obj-C code
• They are slower than if in a .c files
• They cannot use C libraries 
• They can be static

21. What are @try and @catch?

Answers:

• Exception handlers
• Exceptions
• Exception keywords
• All of the above

22. What happens if you release an unretained object twice?

Answers:

• Nothing, too many releases are handled correctly
• Undefined behaviour
• MemoryException is raised
• None of the above

23. What is true regarding strings?

Answers:

• C string literals are automatically mapped to objects
• C string literals can be used in Obj-C
• Obj-C strings are not of static storage
• Obj-C strings are like C strings

24. What can be used as Object instance variables?

Answers:

• int
• structures
• pointers
• unions
• None of the above

25. What can you use to avoid the msgSend function overhead?

Answers:

• SEL
• IMP
• You can’t use anything
• None of the above

26. What is the isa variable in objects?

Answers:

• Object size
• Object memory footprint
• Object class identification
• Object serial number
• None of the above

27. How do you throw an exception?

Answers:

• raise Exception
• @throw exception
• RAISE exception
• THROW exception
• None of the above

28. If you need to allocate custom memory, in which method will you do so?

Answers:

• + alloc
• — alloc
• + init
• — init
• None of the above

29. Which of the following is the fastest?

Answers:

• @synchronized
• Explicit locking
• Condition locking
• Mutex implicit locking

30. What happens if two categories define methods with the same names for the same class?

Answers:

• The code won’t compile
• At runtime, either method will be called
• A runtime exception will be thrown
• None of the above

31. Which of the following does not happen when you throw an exception in a @synchronized block?

Answers:

• The object is deallocated
• The object is unlocked
• An exception is thrown
• None of the above

32. What is true regarding messaging?

Answers:

• Messaging is static and messages are replaced by function call at compile time
• Messaging is fully dynamic, which means you can compile some code that sends a message to a class that doesn’t implement it, and add a category later, in a dynamic library for example
• Messaging is only a syntax sugar to call functions
• None of the above is true

33. What is true regarding @public?

Answers:

• It doesn’t exist in Objective-C — это не подходит
• It breaks encapsulation
• It can be used only on singleton objects
• None of the above

34. What is a SEL?

Answers:

• A selection
• The C type of a message selector
• The C type of a class
• A pointer to a method
• None of the above

35. Which of the following is incorrect?

Answers:

• [self release]
• [super release]
• [AClass release]
• They are all correct

36. What’s the difference between copy and deepCopy?

Answers:

• They are the same
• deepCopy doesn’t exist
• copy creates a copy at the first level, while deepCopy copies the instance variables
• copy creates a proxy object, while deepCopy allocate a new object
• None of the above

37. Which of the following can be inherited?

Answers:

• Categories
• Protocols
• Classes
• None of the above

38. A method can be tagged to be called only by a specific class and its subclasses.

Answers:

• True
• False

39. Which of the following is not recommended?

Answers:

• Adding an (id)sender argument to methods
• Using static variables inside methods
• Using C code inside Obj-C methods
• None of the above

40. A class can have two methods with the same name, but with different argument types.

Answers:

• True
• False

41. A class can conform to only one protocol.

Answers:

• True
• False

42. How do you free an object?

Answers:

• free(obj)
• [obj dealloc]
• [obj release]
• [obj free]
• None of the above

43. What is the id type?

Answers:

• A generic C type that Objective-C uses for an arbitrary object
• A memory address type
• A type to hold serialized objects
• The type used for Classes
• None of the above

44. What is a @finally block?

Answers:

• A block that is executed when the program quits
• A block that is executed within a dynamic library when it’s unloaded
• A block of code that is run whenever an exception is thrown or not
• None of the above

45. Can you send messages to nil?

Answers:

• Yes
• No

46. In which version of Objective-C did the fast enumeration system appear?

Answers:

• 2.0
• 1.5
• 1.0
• 3.0

47. What is the C type used to work with objects in Obj-C?

Answers:

• int
• structure
• pointer
• Array

48. Protocols are like classes; they can inherit.

Answers:

• True
• False

49. What type of variable do you need to use to implement singletons?

Answers:

• static
• auto
• const
• Volatile

50. As categories can’t have instance variables, what class could you use to implement a full class only with categories?

Answers:

• NSArray
• NSMutableDictionary
• NSSet
• None of the above

51. In which version of Objective-C did the properties system appear?

Answers:

• 3.0
• 2.5
• 2.0
• 1.5
• 1.0

52. How do you include the root “Object” class?

Answers:

• #include <Object.h>
• #include <objc/Object.h>
• #include <Object/Object.h>
• #include <ROOT.h>
• It depends on the compiler

53. What is true regarding @protected?

Answers:

• The instance variable is accessible within the class that declares it and within classes that inherit it
• The instance variable is accessible everywhere
• The instance variable is accessible only within the class that declares it.
• This is analogous to private_extern for variables and functions. Any code outside the class implementation’s image that tries to use the instance variable will get a link error
• None of the above

54. In Obj-C 2.0, what do the fast enumeration protocols rely on to provide fast Enumerations?

Answers:

• C arrays
• Java Vectors
• Ruby hash
• Obj-C Array
• None of the above

55. Which C feature is not supported in Obj-C?

Answers:

• Bitfields
• Compound literals
• Structures
• C arrays
• Support is compiler dependant

56. When using the garbage collector, which method, that is normally called without the collector, is not called on your objects where they are collected?

Answers:

• free
• dealloc
• destroy
• Uninit

57. Can an exception caught in @catch be re-thrown?

Answers:

• Yes
• No

58. What is an autoreleased object?

Answers:

• A C object.
• A static object.
• An object that is garbage collected.
• An object that will be released when the current AutoreleasePool is deallocated.
• None of the above

59. What is #import

Answers:

• A namespace import rule
• A namespace definition
• A recursive include
• C preprocessor construct to avoid multiple inclusions of the same file
• None of the above