1. 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
2. Which of the following can be inherited?
Answers:
• Categories
• Protocols
• Classes
• None of the
above
3. Which of the following is the fastest?
Answers:
• @synchronized
• Explicit locking
• Condition
locking
• Mutex implicit locking
4. A method can be tagged to be called only by a specific class and its subclasses.
Answers:
• True
• False
5. 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
6. A class can have two methods with the same name, but with different argument types.
Answers:
• True
• False
7. What are @try and @catch?
Answers:
• Exception
handlers
• Exceptions
• Exception keywords
• All of the above
8. A class can conform to only one protocol.
Answers:
• True
• False
9. How do you free an object?
Answers:
• free(obj)
• [obj dealloc]
• [obj release]
• [obj free]
• None of the
above
10. 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)
11. What is the isa variable in objects?
Answers:
• Object size
• Object memory
footprint
• Object class identification
• Object serial
number
• None of the
above
12. 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
13. 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
14. 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
15. Is the following code a correct allocation?
MyClass myObj;
[&myObj aMessage];
Answers:
• Yes
• No
16. 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
17. 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
18. 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
19. Can you send messages to nil?
Answers:
• Yes
• No
20. In which version of Objective-C did the fast enumeration system appear?
Answers:
• 2.0
• 1.5
• 1.0
• 3.0
21. What can be linked to an Obj-C program without any particular process?
Answers:
• C libraries
• Java jar files
• C++ libraries
• scripts
• Executables
22. What is the C type used to work with objects in Obj-C?
Answers:
• int
• structure
• pointer
• array
23. 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
24. Protocols are like classes; they can inherit.
Answers:
• True
• False
25. What comments are supported in Obj-C?
Answers:
• // Line comments
• /* Block
comments */
• # Line comments
• ; Line comments
• -[[ block
comments ]]
26. 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
27. 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
28. What type of variable do you need to use to implement singletons?
Answers:
• static
• auto
• const
• volatile
29. 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
30. 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
31. How do you throw an exception?
Answers:
• raise Exception
• @throw exception
• RAISE exception
• THROW exception
• None of the
above
32. 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
33. In which version of Objective-C did the properties system appear?
Answers:
• 3.0
• 2.5
• 2.0
• 1.5
• 1.0
34. 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
35. What is the default visibility for instance variables?
Answers:
• @private
• @package
• @public
• @protected
• None of the
above
36. 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
37. 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
38. 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
39. 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
40. Which of the following is incorrect?
Answers:
• [self release]
• [super release]
• [AClass release]
• They are all
correct
41. What can you use to avoid the msgSend function overhead?
Answers:
• SEL
• IMP
• You can't use
anything
• None of the
above
42. 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
43. Which C feature is not supported in Obj-C?
Answers:
• Bitfields
• Compound
literals
• Structures
• C arrays
• Support is compiler dependant
44. What does Obj-C not support?
Answers:
• Instance
variables
• Class variables
• Static variables
• Automatic variables
45. 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
46. 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
47. What is nil?
Answers:
• The null object
• The null class
• It doesn't exist
• None of the
above
48. What can be used as Object instance variables?
Answers:
• int
• structures
• pointers
• unions
• None of the
above
49. Can an exception caught in @catch be re-thrown?
Answers:
• Yes
• No
50. 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
51. 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
52. 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
53. What class specifiers are supported?
Answers:
• FINAL
• STATIC
• FAST
• ITERATIVE
• There is no such thing as class specifiers
54. Which of the following declares a protocol?
Answers:
• @proto
ProtocolName
• protocol
ProtocolName {};
• @protocol ProtocolName
• @interface
<ProtocolName>
• @interface
ProtocolName::Protocol
55. 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
56. If you need to allocate custom memory, in which method will you do so?
Answers:
• + alloc
• - alloc
• + init
• - init
• None of the above
57. 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
58. What is the Obj-C runtime?
Answers:
• A C library
• A compiler
• A language
• A dynamic loader
59. 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
No comments:
Post a Comment