Summary

This document explains the concepts of abstract classes and interfaces in object-oriented programming. It includes examples and questions about each concept. The document covers topics like inheritance, method implementations, and differences between abstract classes and interfaces.

Full Transcript

# concrete class 1. What distinguishes a concrete class from an abstract class? Choices A) A concrete class cannot be inherited from. B) A concrete class can only contain abstract methods. C) A concrete class can be instantiated to create objects. D) A concrete class acts as a blueprint for other cl...

# concrete class 1. What distinguishes a concrete class from an abstract class? Choices A) A concrete class cannot be inherited from. B) A concrete class can only contain abstract methods. C) A concrete class can be instantiated to create objects. D) A concrete class acts as a blueprint for other classes. Answer: (C) A concrete class can be instantiated to create objects. Concrete classes are complete implementations that can create objects, while abstract classes cannot be instantiated directly. 2. Which statement about concrete classes is true? Choices A) Concrete classes only include abstract methods. B) Concrete classes cannot inherit from abstract classes. C) Concrete classes may have no methods defined. D) Concrete classes can be instantiated and create real-world objects. Answer: (D) Concrete classes can be instantiated and create real-world objects. Concrete classes provide complete implementations and can be instantiated, allowing the creation of actual objects. 3. What is an essential property of a concrete class? Choices A) It must implement all inherited methods. B) It can only exist in a single inheritance structure. C) It can include multiple abstract methods without implementation. D) It cannot contain concrete methods. Answer: (A) It must implement all inherited methods. Concrete classes provide complete implementations of all methods, including inherited ones. 4. Which of the following is true about how concrete classes operate within a hierarchy? Choices A) Concrete classes establish a common structure without defining methods. B) Concrete classes can implement abstract methods from their parent classes. C) Concrete classes must have at least one abstract method. D) Concrete classes cannot inherit from other classes. Answer: (B) Concrete classes can implement abstract methods from their parent classes. Concrete classes can implement methods that are abstract in their parent abstract classes to provide functionality. 5. Which of the following best defines a concrete class in object-oriented programming? Choices A) A class that does not require method definitions. B) A class that can be instantiated to create objects. C) A class that serves only as a blueprint for other classes. D) A class that contains only abstract methods. Answer: (B) A class that can be instantiated to create objects. Concrete classes are fully functional and can be instantiated to create objects. 6. How do concrete classes differ in functionality from abstract classes? Choices A) Concrete classes must implement inherited abstract methods. B) Concrete classes cannot be instantiated directly. C) Concrete classes do not enforce any structure. D) Concrete classes cannot contain inherited methods. Answer: (A) Concrete classes must implement inherited abstract methods. Concrete classes are required to implement any inherited abstract methods, unlike abstract classes. 7. In designing a system, when should you opt for using concrete classes? Choices A) When you need shared structures but no specific implementations. B) When you need a blueprint for future classes. C) When you are defining behaviors without method implementations. D) When you want to create instances of a class directly. Answer: (D) When you want to create instances of a class directly. Concrete classes are used when you need to create instances and have specific implementations in your design. 8. What does the implementation of methods in a concrete class signify? Choices A) The class acts solely as a reference for method signatures. B) The methods cannot be overridden by subclasses. C) The methods are defined with their functionality. D) The class is abstract and cannot create objects. Answer: (C) The methods are defined with their functionality. Concrete classes implement methods with their specific functionality, standing in contrast to abstract classes. 9. Which scenario would best illustrate the use of a concrete class? Choices A) Creating specific geometrical shapes like a circle or rectangle. B) Providing method signatures for various shapes. C) Defining a general shape without implementation details. D) Establishing a contract for multiple classes to follow. Answer: (A) Creating specific geometrical shapes like a circle or rectangle. Concrete classes like a circle or rectangle provide specific implementations of the shape using inherited characteristics. 10. An example of a fully functional class that can be used to create objects is: Choices A) Abstract method B) Abstract class C) Concrete class D) Interface Answer: (C) Concrete class Concrete classes are the only type that can be directly instantiated to create objects in programming. >> Abstract Classes > Interfaces > Differences Between Abstract Classes and Interfaces

Use Quizgecko on...
Browser
Browser