What is the difference between a class and a module in OOP?

Object Oriented Programming Questions



47 Short 36 Medium 25 Long Answer Questions Question Index

What is the difference between a class and a module in OOP?

In Object Oriented Programming (OOP), a class is a blueprint or template for creating objects, which defines the properties and behaviors that the objects will have. It encapsulates data and functions into a single unit.

On the other hand, a module is a collection of related functions, variables, and classes that can be used in a program. It is a separate file or unit that can be imported and used in other parts of the program.

The main difference between a class and a module is that a class is used to create objects and define their properties and behaviors, while a module is used to organize and group related functions, variables, and classes together for reusability and maintainability. Classes are used to create instances and represent real-world entities, while modules are used to organize and modularize code for better organization and code reuse.