Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q741: How do you create a new Possession instance with specific values for its properties?
- A: Possession *p = [[Possession alloc] initWithPossessionName:name valueInDollars:value serialNumber:snumber];
- B: Possession *p = [[Possession alloc] init]; [p setPossessionName:name]; [p setValueInDollars:value]; [p setSerialNumber:snumber];
- C: Possession *p = [[Possession alloc] initWithName:name value:value serialNumber:snumber];
- D: Possession *p = [[Possession alloc] initWithName:name value:value serialNumber:snumber];
View Answer
A
Q742: How does Objective-C handle dynamically typed objects?
- A: Uses runtime type checking to handle unknown methods
- B: Uses a static type system to manage all objects
- C: Automatically converts objects to the correct type during compilation
- D: Uses typecasting to manage object types
View Answer
A
Q743: How do you define a property with a specific memory management policy in Objective-C?
- A: @property (nonatomic, strong) NSString *propertyName;
- B: @property (atomic, weak) NSString *propertyName;
- C: @property (nonatomic, copy) NSString *propertyName;
- D: @property (atomic, retain) NSString *propertyName;
View Answer
C
Q744: What does @synthesize do in Objective-C?
- A: Automatically generates getter and setter methods for properties
- B: Defines the initial value of properties
- C: Creates a class method for the properties
- D: Implements default values for properties
View Answer
A
Q745: What is the function of the initWithPossessionName:valueInDollars:serialNumber: initializer method?
- A: Initializes a Possession object with given parameters and returns it
- B: Allocates memory for the Possession object without initializing it
- C: Creates a new instance of Possession without setting its properties
- D: Allocates and initializes a Possession object with default values
View Answer
A
Q746: What is the result of calling [array addObject:[NSNull null]] on an NSArray?
- A: Throws an exception
- B: Adds a nil value to the array
- C: Adds a placeholder object to the array
- D: Appends a new object to the array
View Answer
A
Q747: How do you override a method in Objective-C?
- A: Use the - symbol followed by the method name and implementation
- B: Use the + symbol followed by the method name and implementation
- C: Define a new method with the same name in the subclass
- D: Use the override keyword followed by the method name and implementation
View Answer
C
Q748: How do you log a formatted string with variables in Objective-C?
- A: NSLog(@"Format: %@", variable);
- B: NSLog(@"%@ %d", format, variable);
- C: NSLog(@"Format: %d", variable);
- D: NSLog(@"%@ - %@", variable1, variable2);
View Answer
A
Q749: What does @interface do in Objective-C?
- A: Declares the public interface of a class
- B: Defines the private implementation details of a class
- C: Sets up the memory management for a class
- D: Specifies the class methods available to other classes
View Answer
A
Q750: What is the purpose of the autorelease method in Objective-C?
- A: To manually manage the memory of an object
- B: To add an object to the autorelease pool and release it later
- C: To initialize an object with default values
- D: To directly release an object immediately
View Answer
B