Frequently asked questions and answers of Objective-C in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best Objective-C Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download Objective-C FAQs in PDF form online for academic course, jobs preparations and for certification exams .
Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.
Question-1. What is Objective-C?
Answer-1: Objective-C is a general-purpose, object-oriented programming language used primarily for macOS and iOS development.
Question-2. Who developed Objective-C?
Answer-2: Objective-C was developed by Brad Cox and Tom Love in the early 1980s.
Question-3. What is the primary use of Objective-C?
Answer-3: It is used for building applications for Apple's ecosystem, such as macOS and iOS.
Question-4. What is the syntax to define a class in Objective-C?
Answer-4: Use @interface and @implementation. Example: @interface MyClass : NSObject ... @end.
Question-5. What is a category in Objective-C?
Answer-5: A category is a way to add methods to an existing class without modifying its source code.
Question-6. What is a protocol in Objective-C?
Answer-6: Protocols define a set of methods that a class can choose to implement, similar to interfaces in Java.
Question-7. What are the main data types in Objective-C?
Answer-7: Common data types include int, float, double, BOOL, and objects like NSString.
Question-8. What is a selector in Objective-C?
Answer-8: A selector is a unique identifier that represents the name of a method.
Question-9. How is memory management handled in Objective-C?
Answer-9: Memory management is handled using Automatic Reference Counting (ARC) or manually using retain and release.
Question-10. What is the difference between nonatomic and atomic?
Answer-10: atomic ensures thread safety for property access, while nonatomic does not, offering better performance.
Question-11. How do you define properties in Objective-C?
Answer-11: Use the @property keyword. Example: @property (nonatomic, strong) NSString *name;.
Question-12. What is the @synthesize directive?
Answer-12: @synthesize automatically generates getter and setter methods for properties.
Question-13. What is the difference between copy and strong in property attributes?
Answer-13: copy creates a new copy of the object, while strong retains a reference to it.
Question-14. What is the use of id in Objective-C?
Answer-14: id is a dynamic type that can hold any object.
Question-15. What is nil in Objective-C?
Answer-15: nil is a null pointer to an object, used for uninitialized objects.
Question-16. What is the purpose of instancetype in Objective-C?
Answer-16: instancetype specifies the return type of an initializer method as the class's instance type.
Question-17. What are NSMutableArray and NSArray?
Answer-17: NSArray is immutable, while NSMutableArray allows modification of elements.
Question-18. How is exception handling performed in Objective-C?
Answer-18: Using @try, @catch, and @finally blocks.
Question-19. What is KVC in Objective-C?
Answer-19: KVC (Key-Value Coding) allows accessing an object's properties indirectly using string keys.
Question-20. What is KVO in Objective-C?
Answer-20: KVO (Key-Value Observing) enables observing changes to a property's value.
Question-21. What is the NSObject class?
Answer-21: NSObject is the root class of most Objective-C class hierarchies and provides basic functionality.
Question-22. What are blocks in Objective-C?
Answer-22: Blocks are anonymous functions that capture surrounding variables and can be passed as arguments.
Question-23. How do you define a block in Objective-C?
Answer-23: Example: int (^myBlock)(int) = ^(int x) { return x * x; };.
Question-24. What is the purpose of super in Objective-C?
Answer-24: super is used to call methods in the superclass.
Question-25. What is a dealloc method?
Answer-25: dealloc is called when an object is deallocated to release resources.
Question-26. What are categories used for in Objective-C?
Answer-26: Categories are used to add methods to a class without inheritance.
Question-27. What is the use of @autoreleasepool?
Answer-27: @autoreleasepool manages the release of temporary objects created during a block of code.
Question-28. What is a delegate in Objective-C?
Answer-28: A delegate is a design pattern where one object communicates back to another via predefined methods.
Question-29. What is the difference between weak and strong references?
Answer-29: weak references do not increase an object's retain count, avoiding retain cycles.
Question-30. What is a runtime in Objective-C?
Answer-30: The runtime is a library providing dynamic features like method invocation and introspection.
Question-31. What is message passing in Objective-C?
Answer-31: Message passing involves sending messages to objects using square brackets. Example: [object method].
Question-32. How does Objective-C handle multiple inheritance?
Answer-32: Objective-C does not support multiple inheritance; instead, it uses protocols.
Question-33. What is the @dynamic directive?
Answer-33: @dynamic tells the compiler that accessor methods will be provided at runtime.
Question-34. What is the readonly attribute in properties?
Answer-34: It makes a property read-only, meaning no setter method is generated.
Question-35. What is the difference between instancetype and id?
Answer-35: instancetype is more specific and ensures type checking, while id is more generic.
Question-36. What is a __block variable?
Answer-36: A __block variable allows modification of variables inside a block.
Question-37. How do you define a protocol in Objective-C?
Answer-37: Use the @protocol keyword. Example: @protocol MyProtocol
Question-38. What is the @optional keyword in protocols?
Answer-38: It marks methods in a protocol as optional for implementation.
Question-39. What is the difference between class and instance methods?
Answer-39: Class methods are defined with +, while instance methods use -.
Question-40. What is a property's retain count?
Answer-40: It tracks how many references exist to an object. When it reaches 0, the object is deallocated.
Question-41. What is the use of @private in Objective-C?
Answer-41: @private restricts access to class members outside the class.
Question-42. What is polymorphism in Objective-C?
Answer-42: Polymorphism allows methods to be overridden in subclasses, enabling dynamic method invocation.
Question-43. What is the difference between shallow and deep copy?
Answer-43: A shallow copy duplicates only references, while a deep copy duplicates the objects as well.
Question-44. What is the NSCopying protocol?
Answer-44: NSCopying defines methods for creating copies of objects.
Question-45. What is the isKindOfClass: method?
Answer-45: It checks if an object is an instance of a class or its subclasses.
Question-46. What is the respondsToSelector: method?
Answer-46: It checks if an object can respond to a particular selector.
Question-47. What are NSString and NSMutableString?
Answer-47: NSString is immutable, while NSMutableString can be modified.
Question-48. What is the NSNotificationCenter used for?
Answer-48: It manages the broadcasting of messages across objects.
Question-49. What is the @try and @catch mechanism?
Answer-49: It is used for exception handling in Objective-C.
Question-50. What is the difference between @protocol and @interface?
Answer-50: @protocol defines a contract for methods, while @interface defines a class.
Frequently Asked Question and Answer on Objective-C
Objective-C Interview Questions and Answers in PDF form Online
Objective-C Questions with Answers
Objective-C Trivia MCQ Quiz