OOP Reviewer
OOP Reviewer
Oriented Programming (OOP). This covers the key concepts of encapsulation, inheritance,
polymorphism, and more. At the end, I will also provide an answer key.
A. The ability of a class to derive properties and methods from another class.
B. The bundling of data with the methods that operate on that data.
C. The ability to define multiple methods with the same name but different signatures.
D. The process of calling the appropriate method based on the object type at runtime.
D. When multiple classes have methods with the same name but different
implementations.
A. A single action to behave differently based on the object that invokes it.
A. Encapsulation
B. Polymorphism
C. Inheritance
D. Overloading
A. Creating a new method with the same name but different parameters.
1. B
2. C
3. A
4. B
5. B
6. B
7. B
8. A
9. B
10. A
This set of questions should help reinforce the core concepts of OOP discussed in your
lessons. Let me know if you'd like to adjust or add more questions!
#### 11. What is the difference between **overloading** and **overriding** in Java?
A. Overloading refers to multiple methods with the same name but different signatures,
while overriding refers to redefining a method in a subclass.
C. Overloading occurs only with private methods, while overriding occurs with public
methods.
D. Overloading changes the return type of a method, while overriding changes its
parameters.
#### 13. In the following code, what does the keyword **`this`** represent?
```java
class Car {
Car(String color) {
this.color = color;
}
```
#### 18. The main difference between **abstract classes** and **interfaces** is:
D. Abstract classes can have both concrete and abstract methods, while interfaces can
only have abstract methods.
A. Defining multiple constructors with different parameter lists in the same class.
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Compilation
A. Allows multiple methods with the same name but different parameters.
C. Allows multiple methods with different return types but the same name.
A. Allow two methods to share the same name but different parameters.
C. Allows multiple instances of the class but restricts access to one method.
#### 32. Which of the following statements about **abstract methods** is true?
#### 35. Which of the following is true about **static variables** in Java?
D. Static variables can only be accessed within the class they are declared in.
#### 41. Which of the following is true for **final variables** in Java?
A. They can be modified only by the class in which they are declared.
A. Be declared as static.
B. Return an integer.
C. Be declared as abstract.
D. Be overloaded.
#### 43. **Packages** in Java are used to:
C. Must be static.
D. Defining constructors.
---
### Updated Answer Key:
11. A
12. B
13. A
14. C
15. B
16. B
17. A
18. D
19. B
20. C
21. B
22. B
23. C
24. B
25. A
26. D
27. A
28. A
29. B
30. B
31. A
32. C
33. B
34. C
35. B
36. C
37. A
38. C
39. A
40. B
41. C
42. A
43. C
44. B
45. B
46. A
47. C
48. B
49. C
50. A