0% found this document useful (0 votes)
5 views

Mcqs cs304

The document consists of multiple-choice questions (MCQs) related to object-oriented programming concepts such as inheritance, generalization, specialization, abstract classes, and method overriding. It covers definitions, relationships between classes, and principles like subtyping and encapsulation. The questions aim to assess understanding of fundamental OOP principles and their applications.

Uploaded by

ahsabahsan313
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Mcqs cs304

The document consists of multiple-choice questions (MCQs) related to object-oriented programming concepts such as inheritance, generalization, specialization, abstract classes, and method overriding. It covers definitions, relationships between classes, and principles like subtyping and encapsulation. The questions aim to assess understanding of fundamental OOP principles and their applications.

Uploaded by

ahsabahsan313
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Mcqs cs304

. In object-oriented programming, what is the main benefit of inheritance?

 A) Redundancy
 B) Complexity
 C) Reuse
 D) Specialization

2. What is generalization in object-oriented programming?

 A) Creating multiple unrelated classes with unique attributes


 B) Extracting common characteristics into a new base class
 C) Adding specific characteristics to an existing class
 D) Creating classes with no relationship to each other

3. Which of the following best describes an “Is A” relationship?

 A) Association
 B) Aggregation
 C) Generalization
 D) Composition

4. In an inheritance hierarchy, what is a base class?

 A) A class that inherits characteristics from another class


 B) A class that provides common characteristics to derived classes
 C) A class with only private attributes
 D) A class without any subclasses

5. What is a concrete class?

 A) A class that cannot be instantiated


 B) A class that provides a partial implementation of methods
 C) A fully implemented class that can be instantiated
 D) A class that only contains abstract methods

6. Which of the following describes a specialization in object-oriented programming?

 A) A relationship where classes share no common features


 B) A derived class with additional specific characteristics
 C) A base class that is abstract and cannot be instantiated
 D) None of the above
7. When a derived class has its own unique characteristics in addition to inherited ones, it is
demonstrating which concept?

 A) Generalization
 B) Inheritance
 C) Overriding
 D) Subtyping

8. What is an abstract class in object-oriented programming?

 A) A class that can be instantiated directly


 B) A class with only static methods
 C) A class that cannot be instantiated and serves as a base for other classes
 D) A class without any methods or properties

9. In which scenario is overriding used?

 A) When a derived class needs to add additional properties


 B) When a derived class needs to modify or replace a method from the base class
 C) When a base class does not have any methods
 D) When creating an unrelated class with similar characteristics

10. Subtyping is also referred to as:

 A) Overloading
 B) Extension
 C) Redundancy
 D) None of the above

11. What does a base class encapsulate in the context of generalization?

 A) Unique characteristics for specific classes


 B) Complex algorithms
 C) Common behavior and attributes of derived classes
 D) No characteristics; it serves only as a placeholder

12. What kind of relationship is typically required between base and derived classes in
generalization?

 A) “Uses A” relationship
 B) “Contains A” relationship
 C) “Is A” relationship
 D) “Has A” relationship
 What is the purpose of adding a new class to an existing model with sub-typing and
specialization?
o a) To replace the base class entirely
o b) To reuse some of the base class's state and behavior
o c) To limit the functionality of the base class
o d) To remove all previous class relationships

 What is meant by "sub-typing"?


o a) Creating a derived class that is completely independent of the base class
o b) Creating a derived class that overrides all functionality of the base class
o c) Creating a derived class that is behaviorally compatible with the base class
o d) Creating an unrelated class that doesn't share functionality with the base class

 Which of the following statements is true about sub-typing?


o a) Derived classes cannot use methods from the base class.
o b) Derived classes inherit characteristics from the base class but cannot add new
ones.
o c) Derived classes inherit characteristics from the base class and may add extra
ones.
o d) Derived classes must replace all methods of the base class.

 In sub-typing, what does it mean if a derived class is "behaviorally compatible" with


the base class?
o a) The derived class can only perform new functions not available in the base
class
o b) The derived class can replace the base class in any situation
o c) The derived class has no methods or properties of its own
o d) The derived class does not need to be compatible with the base class

 Which of the following is NOT an example of sub-typing?


o a) A Car class derived from a Vehicle class
o b) A Dog class derived from an Animal class
o c) A Vehicle class derived from a Car class
o d) A Bird class derived from an Animal class
 In object-oriented programming, which feature allows a new class to inherit
properties and behaviors from an existing class?
o a) Polymorphism
o b) Encapsulation
o c) Inheritance
o d) Abstraction

 Which term describes a class that has all the characteristics of a base class, plus
additional characteristics of its own?
o a) Interface
o b) Subclass
o c) Prototype
o d) Encapsulation

 In sub-typing, what happens if the new class does not add any unique behavior to the
base class?
o a) It becomes identical to the base class
o b) It fails to compile
o c) It does not function as a derived class
o d) It loses inheritance properties

 What is the main advantage of inheriting a new class from an existing class in object-
oriented programming?
o a) Reducing the complexity by creating multiple unrelated classes
o b) Allowing the new class to be completely different from existing ones
o c) Reusing code and adding specialization where needed
o d) Increasing code redundancy

 Which of the following is an example of a behaviorally compatible derived class?


o a) Airplane class from FlyingObject
o b) Fruit class from Vehicle
o c) Mountain class from Ocean
o d) Book class from Animal

 What is an example of "extending" an existing class?


o a) Creating a new class that shares nothing with the base class
o b) Creating a new class with the exact same properties as another
o c) Adding new methods and properties to a derived class
o d) Copying the entire base class into a new class

 In sub-typing, which principle ensures that objects of a derived class can be used in
place of a base class?
o a) Abstraction Principle
o b) Liskov Substitution Principle
o c) Encapsulation Principle
o d) Polymorphism Principle

 Which type of relationship best describes inheritance in object-oriented


programming?
o a) "Has-a" relationship
o b) "Is-a" relationship
o c) "Uses" relationship
o d) "Depends-on" relationship

 If a derived class is expected to maintain the behavior of the base class, which of the
following should it NOT do?
o a) Override methods to change behavior
o b) Add additional methods and properties
o c) Replace the base class’s functionality entirely
o d) Use the inherited base class methods as they are

 Which keyword is typically used in object-oriented programming languages to derive
a new class from a base class?
o a) extends
o b) inherits
o c) derive
o d) override

1. Which of the following statements best describes subtyping?

 A) It involves looking at things from bottom to top.


 B) It is another term for generalization.
 C) It involves looking at things from top to bottom.
 D) It restricts the behavior of a derived class.

2. In the context of object-oriented programming, generalization means:


 A) Defining a new class with restricted behavior.
 B) Adding classes with different behavior from existing ones.
 C) Looking at a class hierarchy from bottom to top.
 D) Extending the behavior of a base class in a derived class.

3. When we need to add a class that is behaviorally incompatible with its base
class, we use:

 A) Generalization
 B) Specialization
 C) Inheritance
 D) Encapsulation

4. Specialization refers to:

 A) Deriving a new class that is fully compatible with the base class.
 B) Adding a class that restricts or changes the behavior of the base class.
 C) Extending a base class to add new functionality.
 D) Looking at the class hierarchy from top to bottom.

5. Which of the following statements is true about behaviorally incompatible


classes in specialization?

 A) The base class can always be replaced by the derived class.


 B) The derived class is always compatible with the base class.
 C) The derived class has restricted or different behavior from the base class.
 D) The base class has additional restrictions compared to the derived class.

6. An example of specialization could be:

 A) Adding a class "Adult" with age restriction to the "Person" class hierarchy.
 B) Creating a generic "Vehicle" class for all types of vehicles.
 C) Defining a "Person" class with generalized behavior.
 D) Using subtyping to allow different "Vehicle" subclasses.

. Subtyping and generalization look at class hierarchies from:

 A) Different perspectives, one top to bottom and the other bottom to top.
 B) The same perspective, always top to bottom.
 C) Opposite perspectives, one right to left and the other left to right.
 D) The same perspective, always bottom to top.

8. In a class hierarchy, the concept of generalization focuses on:


 A) Special requirements for derived classes.
 B) Adding unique behaviors to a specific class.
 C) Defining broader, more general characteristics at the top of the hierarchy.
 D) Narrowing down specific behaviors in derived classes.

9. Which concept would you use if you need to create a class with unique
behaviors not found in the base class?

 A) Generalization
 B) Abstraction
 C) Specialization
 D) Aggregation

10. In the example of adding an "Adult" class, the restriction applied is based on:

 A) Behavior differences unrelated to age.


 B) Age as a unique requirement in the "Person" hierarchy.
 C) Additional functionality that the "Person" class does not support.
 D) Removing age constraints for a generalized "Person" class.

1. Which term describes the situation where a derived class provides its own
implementation of a method defined in the base class?

 A) Inheritance
 B) Overloading
 C) Overriding
 D) Encapsulation

2. Which of the following is NOT a reason for overriding a method?

 A) To extend the default behavior


 B) To improve performance
 C) To restrict default behavior
 D) To create new methods

3. When a derived class overrides a base class method, it:

 A) Hides the base class method


 B) Replaces the base class method's behavior with its own
 C) Inherits the base class method's functionality without modification
 D) Deletes the base class method

4. What type of inheritance mechanism is method overriding an example of?

 A) Multiple Inheritance
 B) Single Inheritance
 C) Interface Inheritance
 D) Implementation Inheritance

5. Which of these is an example of specialization in method overriding?

 A) Overriding a base class method to provide derived class-specific behavior


 B) Adding a new method in the derived class
 C) Hiding a method in the base class
 D) Copying base class code to a derived class

6. Which term best describes adding new functionality in a derived class by


overriding a base class method?

 A) Restriction
 B) Specialization
 C) Extension
 D) Abstraction

7. Which concept allows a derived class to enforce limitations on a base class’s


behavior?

 A) Extension
 B) Encapsulation
 C) Restriction
 D) Polymorphism

8. Which of these is true regarding method overriding?

 A) It only applies to private methods


 B) It allows a derived class to replace a base class’s method
 C) It enables overloading a method with a different number of parameters
 D) It limits the visibility of the base class method

10. Overriding a base class method is most useful for:

 A) Eliminating inherited methods


 B) Implementing inheritance
 C) Providing unique functionality for derived class objects
 D) Hiding the base class implementation

1. What is the primary purpose of an abstract class?

 A. To be instantiated directly
 B. To define specific functionality only
 C. To be inherited by other classes
 D. To hold data without any methods

2. Which statement is not true about abstract classes?

 A. They can be instantiated directly


 B. They promote code reuse
 C. They are usually at the top of the class hierarchy
 D. They represent generalized behavior

4. Abstract classes are typically used for which type of concepts?

 A. Concrete implementations
 B. Specific instances only
 C. Generalized or abstract concepts
 D. Specific hardware functions

5. Which of the following best describes an abstract class?

 A. A class that only contains private methods


 B. A class that cannot have subclasses
 C. A class with generalized behavior meant for inheritance
 D. A class that can be instantiated directly

6. In terms of inheritance, where do abstract classes usually exist in the class


hierarchy?

 A. At the bottom of the hierarchy


 B. At or near the top of the hierarchy
 C. In the middle of the hierarchy
 D. In isolated parts of the hierarchy

7. Which feature of abstract classes supports reusability?

 A. Ability to instantiate directly


 B. Generalized methods and properties
 C. Requirement of only static methods
 D. Limited inheritance capability

8. Which of the following statements is true about abstract classes?


 A. They can only contain abstract methods.
 B. They allow instantiation.
 C. They can contain both abstract and concrete methods.
 D. They must contain only private methods.

9. An abstract class represents:

 A. A specific instance
 B. A generalized concept
 C. A collection of data without methods
 D. Only static methods

10. What happens if a class inherits from an abstract class without implementing
all its abstract methods?

 A. It becomes an abstract class itself


 B. It will compile without any issues
 C. It cannot contain any other methods
 D. It will lose access to inherited methods

 What is an abstract class in an object model?


o A) A class that can exist independently
o B) A class used only for creating objects directly
o C) A class representing objects with common attributes, serving as a general class
in class hierarchies
o D) A class implementing specific, real-world entities

 Why can’t abstract classes exist as standalone objects in an object model?


o A) They lack specific attributes
o B) They are designed only for object instantiation
o C) They are meant to serve as a general template with shared characteristics
o D) They are too complex to function independently

 What is the purpose of identifying objects with common attributes when designing
an object model?
o A) To create more objects
o B) To simplify the model by grouping shared characteristics in abstract classes
o C) To eliminate concrete classes
o D) To ensure every object is unique
 Which of the following best describes a concrete class?
o A) A class that implements an abstract concept
o B) A class that provides a general template for other classes
o C) A class created for real-world entities and instantiates objects in a program
o D) A class that cannot instantiate objects directly

 Concrete classes are used for:


o A) Creating abstract classes
o B) Providing specific implementation details in a domain context
o C) Generalizing object models
o D) Finding common attributes among objects

 Which of the following statements is true about concrete objects?


o A) They are theoretical and do not have real-world counterparts
o B) They represent entities visible in the real world
o C) They are only used to create abstract classes
o D) They cannot be instantiated

 When building an object model, objects with shared characteristics should be


grouped into:
o A) Concrete classes
o B) Interfaces
o C) Abstract classes
o D) Methods

 What is the main function of a concrete class in a program?


o A) To represent abstract concepts only
o B) To instantiate objects and implement real-world entities
o C) To serve as a placeholder for abstract methods
o D) To hold only shared characteristics

 Abstract classes are typically found:


o A) At the bottom of the class hierarchy
o B) In the middle of the class hierarchy
o C) At the top of the class hierarchy
o D) As standalone objects

 What distinguishes a concrete class from an abstract class?


o A) Concrete classes cannot have real-world counterparts
o B) Abstract classes provide implementation details, while concrete classes do not
o C) Concrete classes represent real-world entities and can instantiate objects, while
abstract classes cannot
o D) Concrete classes are always at the top of the class hierarchy

 Which of the following statements about a concrete class is true?

 A) A concrete class can only exist as a part of a hierarchy.


 B) A concrete class may exist independently in an object model.
 C) A concrete class is always at the top of the hierarchy.
 D) A concrete class cannot be instantiated.

 In a well-designed object model, where are concrete classes generally located in the class
hierarchy?

 A) At the very top


 B) In the middle or towards the bottom
 C) Outside of the hierarchy
 D) They don't have a specific location in the hierarchy

 Which of the following is true if an abstract class exists in an object model?

 A) The model must also have concrete classes derived from the abstract class.
 B) The model cannot contain any concrete classes.
 C) The abstract class will not be part of any hierarchy.
 D) The object model must not include any other abstract classes.

 What is the purpose of having a concrete class in a class hierarchy with an abstract
class?

 A) To define general behavior for the hierarchy.


 B) To provide a blueprint that cannot be instantiated.
 C) To implement the specific functionalities defined by the abstract class.
 D) To restrict access to the hierarchy.

 If there is no concrete class derived from an abstract class in an object model, what can
be concluded?
 A) The abstract class is redundant.
 B) The object model is correctly structured.
 C) The abstract class can exist independently without issues.
 D) The model is functioning normally.

 Why is it necessary to have concrete classes derived from an abstract class in an object
model?

 A) To increase code readability


 B) To allow the abstract class to be instantiated
 C) To give the hierarchy meaning and functionality
 D) To prevent errors in the object model

You might also like