Object Oriented Programming Midterm Review

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Catherine Halcomb
Catherine Halcomb
Community Contributor
Quizzes Created: 4351 | Total Attempts: 7,027,064
| Attempts: 11 | Questions: 30 | Updated: Oct 7, 2026
Please wait...
Question 1 / 31
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. A static variable is accessed using the ____ name, not through an object.

Explanation

A static variable is associated with the class itself rather than any specific instance of the class. This means it can be accessed using the class name directly, allowing for shared data across all instances. Since static variables belong to the class, they do not require an object to be referenced, making them useful for maintaining values that should be consistent across all instances. This characteristic differentiates static variables from instance variables, which are tied to individual objects.

Submit
Please wait...
About This Quiz
Object Oriented Programming Midterm Review - Quiz

This review focuses on key concepts in Object Oriented Programming, including methods, inheritance, and access modifiers in Java. It evaluates understanding of essential topics such as method signatures, static vs. non-static methods, and the use of the 'this' keyword. This material is valuable for reinforcing foundational knowledge in Java programming.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which of the following statements about encapsulation are correct? Select all that apply.

Submit

3. Match the encapsulation concept with its correct description.

Submit

4. Encapsulation is achieved by declaring fields ____ and providing public getter and setter methods.

Submit

5. What is encapsulation in Java OOP?

Submit

6. Which of the following correctly contrasts method overloading and method overriding?

Submit

7. The @Override annotation is mandatory for a method to successfully override a superclass method.

Submit

8. What is method overriding?

Submit

9. Match each type of inheritance with its correct description.

Submit

10. Which access modifier should be used for superclass members that are intended to be visible in subclasses but not to other classes?

Submit

11. A subclass calls its superclass constructor using the ____ keyword.

Explanation

In object-oriented programming, when a subclass is created, it often needs to initialize its parent class to ensure that inherited properties and methods are properly set up. The `super` keyword is used for this purpose, allowing the subclass to invoke the constructor of its superclass. This ensures that any necessary initialization defined in the superclass is executed before the subclass adds its own specific features. By using `super`, the subclass can build upon the foundation provided by the superclass, promoting code reuse and maintaining the hierarchical structure of classes.

Submit

12. Constructors are inherited automatically by a subclass from its superclass.

Explanation

Constructors are not inherited in the same way as methods or properties in object-oriented programming. While a subclass can invoke a superclass constructor using the `super` keyword, it does not automatically inherit the constructor itself. Each class must define its own constructors, even if they call the superclass constructor. This distinction ensures that constructors can be tailored to the specific needs of each class, maintaining encapsulation and proper initialization of objects.

Submit

13. Which keyword is used in Java to implement class inheritance?

Explanation

In Java, the keyword "extends" is used to establish a class inheritance relationship. When a class extends another class, it inherits the properties and methods of the parent class, allowing for code reuse and the creation of a hierarchical class structure. This mechanism enables developers to create more specialized subclasses that build upon the functionality of existing classes, promoting modularity and maintainability in the code. Other options like "implements" are used for interfaces, while "super" refers to the parent class in method calls.

Submit

14. What is inheritance in Java OOP?

Explanation

Inheritance in Java OOP is a fundamental concept that allows one class (the subclass) to inherit properties and behaviors (methods) from another class (the superclass). This promotes code reusability and establishes a hierarchical relationship between classes. By using inheritance, developers can create a new class that builds upon the existing functionality of an existing class, enabling easier maintenance and extension of code. This mechanism allows for the creation of specialized classes that can have additional features while still retaining the characteristics of the parent class.

Submit

15. Which of the following correctly describes an instance variable?

Explanation

An instance variable is a property defined in a class that holds data specific to each object created from that class. Unlike class variables, which are shared among all instances, each object maintains its own unique copy of the instance variable. This allows objects to store distinct values, enabling them to represent different states or characteristics while still belonging to the same class.

Submit

16. What is a method in Java?

Explanation

In Java, a method is a block of code that performs a specific task or operation. It consists of a series of statements that are executed when the method is called. Methods allow for code reusability and organization, enabling programmers to break down complex problems into smaller, manageable parts. By encapsulating functionality, methods help in maintaining clean and understandable code, making it easier to debug and enhance.

Submit

17. Local variables can have access modifiers such as public or private.

Explanation

Local variables are defined within a method or block of code and are not accessible outside of that scope. Access modifiers like public or private are used to control the visibility of class members (fields and methods) at the class level, not for local variables. Since local variables exist only within their specific context and do not have a visibility scope that extends beyond that, they cannot be assigned access modifiers. Thus, the statement is false.

Submit

18. Match the variable type with its correct description.

Submit

19. What is the purpose of the 'this' keyword in Java?

Explanation

In Java, the 'this' keyword is used within an instance method or constructor to refer to the current object. It helps to clarify which variables are instance variables and which are parameters, particularly when they have the same name. By using 'this', developers can avoid ambiguity and ensure that they are accessing the correct data associated with the object. This enhances code readability and maintainability, making it clear that the code is working with the instance's properties rather than local method parameters.

Submit

20. Which keyword is used to create a new object from a class in Java?

Explanation

In Java, the keyword "new" is used to instantiate a new object from a class. When you use "new," it allocates memory for the object and calls the class constructor to initialize it. This is essential for creating instances of classes, allowing you to work with the object's properties and methods. Other keywords like "this" and "super" serve different purposes, such as referencing the current object or accessing superclass methods and properties, respectively. Therefore, "new" is the specific keyword that facilitates object creation in Java.

Submit

21. What is a class in Java?

Explanation

In Java, a class serves as a blueprint for creating objects, encapsulating data and behavior. It defines attributes (variables) that represent the state of the object and methods (functions) that dictate its behavior. By using classes, developers can create structured and reusable code, allowing for the creation of multiple objects with similar characteristics and functionalities. This object-oriented approach enhances organization and modularity in programming, making it easier to manage and scale applications.

Submit

22. A static method can be overridden by a subclass.

Explanation

Static methods belong to the class itself rather than to instances of the class. As such, they cannot be overridden in the same way that instance methods can. When a static method is defined in a subclass with the same name and parameters as in the superclass, it is known as method hiding, not overriding. This means that the static method in the subclass will not replace the static method in the superclass; instead, both methods coexist, and the one that gets called depends on the reference type, not the object type.

Submit

23. Which feature distinguishes a static method from a non-static method?

Explanation

Static methods belong to the class itself rather than any specific instance, allowing them to be invoked directly using the class name. This means they do not require an object of the class to be created first. In contrast, non-static methods are tied to instances of the class and must be called on an object. This distinction is crucial for understanding how methods operate within object-oriented programming, particularly regarding memory management and method accessibility.

Submit

24. To call a non-static method from a static context like main(), you must ____.

Explanation

In Java, non-static methods belong to instances of a class, while static methods belong to the class itself. Since the `main()` method is static, it cannot directly call non-static methods without an instance of the class. To access a non-static method, you first need to create an object of that class. This object allows you to invoke the non-static method, enabling access to instance-specific data and behavior. Thus, creating an object is essential to call non-static methods from a static context.

Submit

25. A static method belongs to the class itself, not to an individual object.

Explanation

A static method is associated with the class rather than any specific instance of that class. This means it can be called on the class itself without needing to create an object. Static methods are often used for utility functions that don't require access to instance variables or methods. Since they belong to the class, they can be accessed directly using the class name, making them useful for operations that are relevant to the class as a whole rather than to individual objects.

Submit

26. Which of the following is NOT a valid way to overload a method?

Explanation

Method overloading allows multiple methods to have the same name but differ in parameters. However, simply changing the return type of a method does not qualify as overloading because it does not affect the method signature, which is defined by the method name and parameter list. Therefore, methods with the same name and parameter list but different return types cannot coexist, making "Different return type only" an invalid way to overload a method.

Submit

27. Method overloading is valid when methods have the same name but ____.

Explanation

Method overloading allows multiple methods in the same class to share the same name, enhancing code readability and usability. However, to distinguish between these methods, they must have different parameter lists, which can vary in the number of parameters, types of parameters, or both. This differentiation enables the compiler to determine which method to invoke based on the arguments passed during a method call, facilitating polymorphism and improving the flexibility of the code.

Submit

28. Which access modifier makes a method visible only within its own class?

Explanation

The private access modifier restricts visibility of a method to the class in which it is declared. This means that the method cannot be accessed or invoked from outside the class, even by subclasses or other classes within the same package. This encapsulation is a fundamental principle of object-oriented programming, promoting data hiding and protecting the integrity of the class's internal state by preventing unauthorized access or modification.

Submit

29. What does the method signature consist of?

Explanation

A method signature uniquely identifies a method within a class and consists of the method name and its parameter list. The method name distinguishes it from other methods, while the parameter list defines the number and types of inputs the method can accept. Together, they allow the compiler to differentiate between methods, especially when overloading occurs, ensuring that the correct method is invoked based on the arguments provided during a call.

Submit

30. Which return type is used when a method does not return any value?

Explanation

In programming, particularly in languages like Java, C++, and C#, the return type "void" indicates that a method does not return any value. When a method is defined with a return type of void, it can perform operations or execute code without providing a result back to the caller. This is useful for methods that perform actions, such as printing to the console or modifying data, where the return of a value is unnecessary. Thus, "void" effectively communicates that the method's purpose is to execute rather than to calculate and return a value.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
A static variable is accessed using the ____ name, not through an...
Which of the following statements about encapsulation are correct?...
Match the encapsulation concept with its correct description.
Encapsulation is achieved by declaring fields ____ and providing...
What is encapsulation in Java OOP?
Which of the following correctly contrasts method overloading and...
The @Override annotation is mandatory for a method to successfully...
What is method overriding?
Match each type of inheritance with its correct description.
Which access modifier should be used for superclass members that are...
A subclass calls its superclass constructor using the ____ keyword.
Constructors are inherited automatically by a subclass from its...
Which keyword is used in Java to implement class inheritance?
What is inheritance in Java OOP?
Which of the following correctly describes an instance variable?
What is a method in Java?
Local variables can have access modifiers such as public or private.
Match the variable type with its correct description.
What is the purpose of the 'this' keyword in Java?
Which keyword is used to create a new object from a class in Java?
What is a class in Java?
A static method can be overridden by a subclass.
Which feature distinguishes a static method from a non-static method?
To call a non-static method from a static context like main(), you...
A static method belongs to the class itself, not to an individual...
Which of the following is NOT a valid way to overload a method?
Method overloading is valid when methods have the same name but ____.
Which access modifier makes a method visible only within its own...
What does the method signature consist of?
Which return type is used when a method does not return any value?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!