NEW
Font size
WorksheetsObject-Oriented Programming Quiz
Total questions: 40
Worksheet time: 20mins
Which of the following is not a characteristic of Object-Oriented Programming?
Encapsulation
Polymorphism
Compilation
Inheritance
In OOP, an object is best described as:
A function inside a program
A variable holding primitive data only
An instance of a class
A block of memory allocated at compile time
Which advantage of OOP allows code to be reused across multiple programs?
Abstraction
Inheritance
Encapsulation
Polymorphism
Which term refers to bundling data and the methods that operate on that data into a single unit?
Abstraction
Encapsulation
Inheritance
Overloading
Which of the following is true about OOP?
It only works in compiled languages.
It increases code reusability and maintainability.
It eliminates the need for algorithms.
It is not used in large-scale systems.
Which principle allows one class to acquire properties and behaviors from another?
Inheritance
Abstraction
Encapsulation
Aggregation
Which of these is a disadvantage of OOP?
Higher memory usage
Easier debugging
Better code modularity
More natural mapping to real-world problems
Which is not an OOP language?
Java
C++
Python
C
UML stands for:
Unified Modeling Language
Universal Machine Language
Unified Method Logic
User Model Layout
In UML, which diagram is used to show interactions between objects?
Class Diagram
Sequence Diagram
State Diagram
Use Case Diagram
A UML class diagram displays:
The steps of a program
The attributes and methods of classes and their relationships
The runtime flow of messages
The end-user interface
Which UML diagram represents system behavior from the user’s point of view?
Use Case Diagram
Class Diagram
Activity Diagram
Sequence Diagram
In a UML class diagram, a + symbol before a method name means:
Protected
Private
Public
Package-private
Which UML relationship indicates that one class is part of another?
Association
Aggregation
Composition
Generalization
Which diagram best models the workflow of a process?
Sequence Diagram
Activity Diagram
State Diagram
Class Diagram
In UML, generalization is used to represent:
Data hiding
Inheritance hierarchy
Multiple classes interacting
User interface design
Polymorphism in OOP allows:
Multiple methods with the same name but different implementations
A single object to have multiple instances
Classes to inherit multiple parents
Objects to encapsulate data
Which type of polymorphism occurs at compile time?
Runtime polymorphism
Method overriding
Method overloading
Dynamic dispatch
Method overriding is an example of:
Compile-time polymorphism
Runtime polymorphism
Multiple inheritance
Encapsulation
Which keyword in Java is used to achieve runtime polymorphism?
static
final
super
override
Which of these is not an example of polymorphism?
Function overloading
Method overriding
Operator overloading
Data hiding
In Java, operator overloading:
Is supported for all operators
Is not supported for user-defined operators
Only works for arithmetic operators
Can be applied to new operators
Which statement is true?
Overloading changes method signatures; overriding changes method bodies.
Overloading is runtime; overriding is compile-time.
Overloading requires inheritance.
Overriding requires different method names.
Polymorphism helps in:
Reducing memory usage
Writing generic and reusable code
Removing inheritance
Improving compilation speed
Encapsulation primarily achieves:
Code duplication
Data hiding
Inheritance
Multiple instantiation
Which access modifier allows class members to be accessed only within the same class?
public
protected
private
default
A getter method is used to:
Retrieve the value of a private variable
Set the value of a private variable
Delete a variable
Create a variable
A setter method should generally:
Return a boolean
Take no parameters
Validate the input before setting the variable
Only work with static variables
In OOP, encapsulation:
Prevents inheritance
Separates interface from implementation
Always makes variables public
Requires UML diagrams
Which statement is correct?
Encapsulation means hiding methods only.
Encapsulation can be achieved using access modifiers.
Encapsulation is the same as polymorphism.
Encapsulation is only used in Java.
Which type of inheritance is not supported directly in Java?
Single
Multilevel
Multiple (using classes)
Hierarchical
Which keyword is used in Java to inherit a class?
extends
implements
inherits
super
Which type of inheritance involves one superclass and multiple subclasses?
Multiple
Multilevel
Hierarchical
Hybrid
What is inherited when a subclass extends a superclass?
Constructors and private fields
Public and protected members
Only static methods
Only public fields
Which statement is correct about method overriding?
Access level can be more restrictive in subclass.
Return type must be exactly the same or covariant.
Method name must be different.
It happens at compile time.
Abstraction in OOP refers to:
Hiding the implementation details and showing only the functionality
Hiding data members from other classes
Using multiple classes together
Reusing code across projects
In Java, which keyword is used to declare an abstract class?
interface
abstract
virtual
final
Which of these statements is true about abstract methods?
They must have a body.
They can be declared in abstract or concrete classes.
They are implemented in the subclass.
They cannot be overridden.
Which of these can achieve 100% abstraction in Java?
Abstract class
Interface
Concrete class
Static class
Which of the following is a benefit of abstraction?
Improved performance
Reduced execution time
Easier maintenance and scalability
Automatic memory management
