Relationships Flashcards
What is the first step in the object-oriented design process?
A) Identifying the classes
B) Developing a prototype
C) Doing the proper analysis
D) Creating a high level model
Correct Answer: C
What does a class in object-oriented programming typically include?
A) Only data members
B) Only function members
C) Data members and function members
D) None of the above
Correct Answer: C
Which of the following is NOT a class modifier in C#?
A) Public
B) Private
C) External
D) Protected
Correct Answer: C
Which access modifier in C# makes code accessible only within the same class?
A) Public
B) Private
C) Protected
D) Internal
Correct Answer: B
In object-oriented design, what is a ‘message’?
A) A type declaration within a class
B) An operation to retrieve attribute information
C) A method invocation on an object
D) A class modifier
Correct Answer: C
What kind of relationship does ‘association’ describe in object-oriented design?
A) A dependent, parent-child relationship
B) A relationship where each object can exist independently
C) A relationship that shares attributes only
D) A permanent, unbreakable link between objects
Correct Answer: B
What is ‘aggregation’ in the context of object-oriented design?
A) Combining different classes into one
B) A dependent object within another object
C) Objects that can exist independently but form a whole
D) Objects that cannot exist without their parent object
Correct Answer: C
Which of the following best describes ‘composition’?
A) A weak form of connection similar to association
B) Objects can exist independently
C) Objects cannot exist independently of their parent object
D) The subclass doesn’t inherit any properties from the superclass
Correct Answer: C
Inheritance in object-oriented design is used to:
A) Show that one class is composed of several other classes
B) Indicate that one class can use the properties and methods of another class
C) Describe a relationship where objects are completely independent
D) Allow a class to pass on its properties and methods to subclasses
Correct Answer: D
Which of the following is a guideline for using inheritance correctly?
A) Always prefer inheritance over attributes
B) Use inheritance to represent ‘is-a’ relationships
C) Subclasses should change the existing features of the superclass
D) Inheritance should be used in all classes
Correct Answer: B
What does the ‘Protected’ access modifier do in C#?
A) Allows access from any class within any assembly
B) Allows access only within its own assembly
C) Allows access within the same class and inherited classes
D) Completely restricts access from other classes
Correct Answer: C
Which of the following statements about class modifiers is true?
A) Public classes are accessible only within the same assembly
B) Private classes are accessible from any assembly if inherited
C) Protected internal access allows for the widest accessibility within the same assembly
D) Internal classes are hidden from other assemblies but visible within their own
Correct Answer: D
A method in a class is typically invoked by what means in object-oriented programming?
A) Instantiation
B) Declaration
C) Messaging
D) Composition
Correct Answer: C
Which scenario is an example of ‘composition’ in object-oriented programming?
A) A classroom and its students where students can exist without the classroom
B) A car model and its options where the options are exclusive to the model
C) A department and its teachers where teachers can belong to multiple departments
D) A house and its rooms where the rooms cannot exist without the house
Correct Answer: D