Visual Programming MCQs with Answers
Practice important Visual Programming MCQs with answers and explanations.
Multiple Choice Questions
Q751: What does the dealloc method do in Objective-C?
- A: Initializes an object
- B: Sets the retain count of an object
- C: Releases the object's retained references and cleans up
- D: Creates a new instance of an object
View Answer
C
Q752: What is the correct way to implement a description method that autoreleases the string object?
- A: return [descriptionString autorelease];
- B: return [[NSString alloc] initWithFormat:@"..."];
- C: return [NSString stringWithFormat:@"..."];
- D: return [descriptionString release];
View Answer
A
Q753: How do you correctly release an object that you no longer need?
- A: Call [object release]
- B: Call [object retain]
- C: Call [object autorelease]
- D: Do nothing
View Answer
A
Q754: What is the purpose of the retain method in Objective-C?
- A: To create a new instance of an object
- B: To increase the reference count of an object
- C: To decrease the reference count of an object
- D: To initialize an object with default values
View Answer
B
Q755: How do you handle memory management when returning an object from a method?
- A: Always retain the object
- B: Always autorelease the object
- C: Release the object before returning it
- D: Use autorelease if you do not want to take ownership
View Answer
D
Q756: What is the purpose of the @interface keyword in Objective-C?
- A: Declares the public interface of a class
- B: Defines the private implementation details of a class
- C: Specifies the class methods available to other classes
- D: Initializes an object and sets its properties
View Answer
A
Q757: What is the purpose of the @property keyword in Objective-C?
- A: Declares an instance variable
- B: Automatically generates getter and setter methods
- C: Creates a class method for the property
- D: Defines a static variable
View Answer
B
Q758: What does the iboutlet keyword signify in an Objective-C class?
- A: It designates a property that can be connected to a user interface element in Interface Builder
- B: It specifies a method that will be triggered by a user interface element
- C: It declares a private method only accessible within the class
- D: It initializes the user interface elements
View Answer
A
Q759: How do you connect a user interface element to a property in Interface Builder?
- A: Control-drag from the interface element to the code file
- B: Directly type the connection name in the code file
- C: Use the connect method in the code file
- D: Create a manual reference in the code file
View Answer
A
Q760: How is the showQuestion method implemented to handle the case when the last question is reached?
- A: It resets currentQuestionIndex to zero and displays the first question
- B: It logs an error and exits the application
- C: It hides the question and displays a message
- D: It loops through the questions and displays a random question
View Answer
A