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
In object-oriented programming, what represents an ‘is-a’ relationship?
A) Association
B) Composition
C) Inheritance
D) Aggregation
Correct Answer: C
Which of the following is NOT a function member of a class?
A) Indexer
B) Operator
C) Modifier
D) Event
Correct Answer: C
What does the ‘private protected’ access modifier in C# mean?
A) The member is accessible only within its declaring class, or types derived from the declaring class within any assembly.
B) The member is accessible within its own assembly, through derived classes only.
C) The member is accessible anywhere within its own assembly.
D) The member is accessible only within its declaring class.
Correct Answer: B
Which of the following best describes the term ‘attributes’ in an object’s context?
A) Methods used to manipulate data
B) Data members and the operations that manipulate them
C) Metadata providing additional information about a class’s behavior
D) Private fields only accessible within the same class
Correct Answer: C
What is the main purpose of the ‘statement of work’ in the object-oriented design process?
A) To identify potential classes and their relationships
B) To describe the problem and outline the solution approach
C) To prototype potential end solutions
D) To provide a detailed class diagram
Correct Answer: B
In C#, which access modifier would you choose to allow the class to be accessible only within the same assembly?
A) Public
B) Private
C) Protected
D) Internal
Correct Answer: D
How do classes in an object-oriented program typically interact with each other?
A) By changing each other’s data directly
B) By invoking methods through messages
C) By inheriting each other’s private members
D) By sharing a single interface for all interactions
Correct Answer: B
What represents a ‘has-a’ relationship in object-oriented design?
A) Inheritance
B) Aggregation
C) Messaging
D) Association
Correct Answer: B
Which of the following is an example of a valid ‘is-a’ relationship in object-oriented design?
A) A library and its books
B) A person and their address
C) A bird is an animal
D) A car is a type of wheel
Correct Answer: C