OOP Reviewer PDF
Document Details
Uploaded by Deleted User
Tags
Related
Summary
This document is a review quiz on object-oriented programming (OOP). It includes a variety of question types, such as identification, multiple choice, and true/false, covering core OOP concepts. The document also contains an introduction to OOP, explaining core concepts and advantages over procedural programming.
Full Transcript
**REVIEW QUIZ (OOP)** **PART 1. IDENTIFICATION** 1. - 2. - 3. - 4. - 5. - 6. - 7. - 8. - 9. - 10. - 11. - 12. - 13. - 14. - 15. - **PART 2. MULTIPLE CHOICE** 1.What does OOP stand for? - 2.Whic...
**REVIEW QUIZ (OOP)** **PART 1. IDENTIFICATION** 1. - 2. - 3. - 4. - 5. - 6. - 7. - 8. - 9. - 10. - 11. - 12. - 13. - 14. - 15. - **PART 2. MULTIPLE CHOICE** 1.What does OOP stand for? - 2.Which of the following best describes a class in OOP? - 3\. In OOP, what is an object? - 4\. Which of the following correctly defines encapsulation? - 5\. What is the purpose of a constructor in a class? - 6\. Which of these access modifiers restricts access to class members only within the class itself? - 7\. What is a destructor used for in OOP? - 8\. Which of the following is NOT a feature of OOP? - 9\. In a class, which of the following methods allows external access to a private attribute? - 10\. Which term refers to the ability of different objects to respond to the same method in different ways? - 11\. A software company is designing a program for an online shopping platform. Each product has attributes such as name, price, and stock availability. Which of the following should be implemented to ensure that the price of a product is always greater than zero when setting its value? - 12\. In a video game development project, you have a Player class and an Enemy class. Both classes need to have a move() method, but the behavior should be different for each class. What OOP concept should be applied? - 13\. Consider a car dealership management system. There are Sedan and SUV classes that inherit common functionality from a parent Car class. If the Car class has a method displayDetails(), but you want each type of car to show its specific details, what should you do? - 14\. A bank application includes an Account class that has an attribute for the account balance. If you want to prevent direct modification of the balance but allow controlled access, what should you implement? - 15\. In a hospital management system, there is a Doctor class and a Patient class. Both classes share some common properties, such as name and age, but their behavior differs. What should be implemented to handle this? - 16\. What is the correct syntax for creating an instance of a class Person in many OOP languages? - 17\. Which of the following allows subclasses to modify the behavior of inherited methods? - 18\. What is the purpose of using the protected access modifier in a class? - 19\. In OOP, what does method overriding allow? - 20\. Which OOP principle enables you to define a single interface, but allows multiple implementations? - **PART 3. TRUE OR FALSE** 1. - 2. - 3. - 4. - 5. - 6. - 7. - 8. - 9. - 10. - 11. - 12. - 13. - 14. - 15. - **INTRODUCTION TO OOP** OOP **[(OBJECT- ORIENTED PROGRAMMING)]** - - **Core concepts of OOP** - - - - - - - - - - - - - **Advantages of OOP over Procedural** - - - - - **Two main aspects of OOP** **Class** - [blueprint for creating objects]. It defines a set of attributes and methods that the objects created from the class will have **Object** - [instance of a class]. It represents a specific realization of the class with actual values for the attributes defined by the class. - - **Attributes** - declared as variables within the class definition using keywords that match their visibility. **Methods** - a procedure associated with a class. A method defines the behavior of the objects that are created from the class. Another way to say this, is that, a method is an action that an object is able to perform. **Define a Class** - - **Define a Object** - - - - - - **\$this keyword** - refers to the current object, and is only available inside methods. \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ **GETTER AND SETTER** **Getter method** - a special function that allows you to access the value of a private or protected property of a class from outside the class **Setter method** - a special function used to set or modify the value of a private or protected property within a class. **Getters and Setters: What Are They?** - - - - **Why Use Getters and Setters?** 1. 2. 3. 4. SUMMARY - - - - \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ **INHERITANCE** **Inheritance** - when a class derives from other class - - \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ **CONSTRUCTOR, DESTRUCTOR, AND ACCESS MODIFIERS** **Constructor** - allows you to ***initialize an object's properties*** upon creation of the object \- If you create ***a \_\_construct() function***, PHP will automatically call this function when you ***create an object from a class***. **Destructor** - called when the ***object is destructed*** or the script is stopped or exited **Access Modifiers** - - - - - \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ **METHOD OVERRIDING** **Function Overriding** - - - - - - **Final Keyword** - - -