Object-Oriented Programming: Classes, Objects and Pillars
Complete notes on object-oriented programming concepts for exams: class and object, the four pillars, constructors, inheritance types and languages with their developers.
By GK24 Editorial Team· Published · 5 min read

Object-oriented programming, usually shortened to OOP, is a way of writing software in which the program is built out of objects that hold both data and the operations on that data, instead of a long list of instructions acting on separate variables. The approach became the standard for large software because it keeps related things together and lets code be reused. In competitive exams the topic is almost entirely definitional: a question gives you a one-line description and asks for the feature, or gives a feature and asks for the language or its developer. Learning the four pillars with one example each, and the small table of languages and their creators, is enough to answer nearly every question asked from this chapter.
From procedural to object-oriented programming
In procedural programming, as in C, FORTRAN or COBOL, a problem is broken into functions and the data is passed between them, so any function can change any global variable. In object-oriented programming the problem is broken into objects; the data of an object is normally kept private and can be changed only by the methods of that object. The result is less accidental damage to data, easier maintenance of large programs and simpler reuse. Procedural code is said to be function-centred and object-oriented code data-centred, a contrast examiners state in exactly those words.
Class and object: the basic pair
A class is a blueprint or template that defines what data members and member functions its members will have; writing a class does not by itself reserve memory for data members. An object is an instance of a class, created from that blueprint, and it occupies memory. Student may be a class, while Rahul and Meena are objects of it. The variables inside are called data members or attributes and the functions are called member functions or methods. One class can have any number of objects. When one object calls the method of another, the older textbooks call it message passing.
The four pillars of OOP
| Feature | What it means | Everyday example |
|---|---|---|
| Encapsulation | Wrapping data and the methods that work on it into a single unit, the class, and keeping the data private | A capsule holding the medicine; a bank account whose balance can change only through deposit and withdraw methods |
| Abstraction | Showing only the essential features to the user and hiding the internal implementation | A car accelerator: you press it without knowing the engine design |
| Inheritance | A new class acquiring the properties and behaviour of an existing class, which allows reuse | Car and Bus inheriting from the class Vehicle |
| Polymorphism | The same name behaving differently in different situations, from the Greek for many forms | One method name area used for a circle and a rectangle |
Many textbooks add two more ideas to this list, data hiding and modularity, but when a paper asks for the basic features of OOP the expected answer is the four above.
The terms that carry marks
- Constructor: a special member function with the same name as the class that is called automatically when an object is created, usually to initialise it. It returns no value, not even void.
- Destructor: the member function called automatically when an object is destroyed, written with a tilde before the class name in C++.
- Function overloading: several functions with the same name but different parameter lists in the same class. It is resolved by the compiler, so it is called compile-time or static polymorphism.
- Function overriding: a derived class redefining a method of its base class. It is resolved while the program runs, so it is called run-time or dynamic polymorphism, achieved in C++ through virtual functions.
- Access specifiers: private members are available only inside the class, protected members also inside derived classes, and public members anywhere. Private is the default in a C++ class.
- Abstract class: a class that cannot be instantiated and exists to be inherited; in C++ it is a class with at least one pure virtual function, and in Java an interface serves a similar purpose.
Types of inheritance
Single inheritance has one base and one derived class. Multiple inheritance gives one derived class two or more base classes. Multilevel inheritance forms a chain, A to B to C. Hierarchical inheritance gives one base class several derived classes. Hybrid inheritance combines these forms. The class that is inherited from is the base, parent or super class, and the new one is the derived, child or sub class. C++ supports multiple inheritance, Java does not support it with classes and achieves the same effect with interfaces, a difference papers like to test.
Languages and their creators
| Language | Developer | Note |
|---|---|---|
| Simula 67 | Ole-Johan Dahl and Kristen Nygaard | Regarded as the first object-oriented language; introduced classes and objects |
| Smalltalk | Alan Kay and his team at Xerox PARC | Alan Kay coined the term object-oriented programming; a purely object-oriented language |
| C++ | Bjarne Stroustrup, Bell Laboratories | Began as C with Classes and was named C++ in 1983; supports both procedural and object-oriented styles |
| Java | James Gosling, Sun Microsystems | Released in 1995, first called Oak; platform independent through the Java Virtual Machine |
| Python | Guido van Rossum | Released in 1991; supports object-oriented and other styles |
| C sharp | Microsoft | Developed for the dot NET platform; object-oriented from the start |
Why OOP is preferred, and its cost
Objects can be reused in other programs, data is protected from accidental change, teams can work on separate classes at the same time, and a change inside a class does not disturb the rest of the program as long as its interface stays the same. The price is that object-oriented programs are usually larger, need more design work before coding, and can run a little slower than tight procedural code. Languages such as C++ and Python that allow both styles are called hybrid or multi-paradigm languages, while Smalltalk is held up as a pure object-oriented language.
Exam Point of View
Papers ask three things from this chapter. First, definition to term: data plus functions in one unit is encapsulation, hiding implementation is abstraction, reuse is inheritance, many forms is polymorphism. Second, language to developer: Simula with Dahl and Nygaard, Smalltalk with Alan Kay, C++ with Bjarne Stroustrup, Java with James Gosling, Python with Guido van Rossum. Third, the fine distinctions: overloading against overriding, class against object, private against protected, and the fact that Java does not allow multiple inheritance through classes. Questions are single-statement and need no coding.
Important Facts
| First OOP language | Simula 67, by Ole-Johan Dahl and Kristen Nygaard |
|---|---|
| Term coined by | Alan Kay, who led Smalltalk at Xerox PARC |
| Four pillars | Encapsulation, abstraction, inheritance, polymorphism |
| C++ | Bjarne Stroustrup, Bell Laboratories; named C++ in 1983 |
| Java | James Gosling, Sun Microsystems; released 1995, first called Oak |
| Python | Guido van Rossum, released in 1991 |
| Constructor | Same name as the class, called on object creation, returns no value |
| Compile-time polymorphism | Function and operator overloading |
| Run-time polymorphism | Function overriding, through virtual functions in C++ |
| Types of inheritance | Single, multiple, multilevel, hierarchical, hybrid |
| Default access in a C++ class | Private |
Practice MCQs on this topic
Which of the following is regarded as the first object-oriented programming language?
- A.Simula 67
- B.FORTRAN
- C.COBOL
- D.BASIC
Show answer
Simula 67, designed by Ole-Johan Dahl and Kristen Nygaard, introduced the ideas of class, object and inheritance and is therefore treated as the first object-oriented language, from which C++ and Java later borrowed.
Read the full explanation →Which of the following is NOT counted among the four basic features of object-oriented programming?
- A.Abstraction
- B.Inheritance
- C.Recursion
- D.Polymorphism
Show answer
Recursion is a general programming technique in which a function calls itself, and it works equally well in procedural languages such as C, so it is not a feature of the object-oriented approach.
Read the full explanation →Wrapping up of data and the functions that operate on that data into a single unit is called
- A.Inheritance
- B.Encapsulation
- C.Overloading
- D.Compilation
Show answer
Encapsulation means binding the data members and the member functions that act on them inside one unit, the class, and keeping the data private so that it can be reached only through the methods provided; the standard illustration is a capsule holding the medicine inside it.
Read the full explanation →Showing only the essential features of an object to the user while hiding its internal details is known as
- A.Abstraction
- B.Encapsulation
- C.Inheritance
- D.Instantiation
Show answer
Abstraction presents only what the user needs, such as the accelerator and brake of a car, and keeps the internal working out of sight; in C++ it is obtained through abstract classes with pure virtual functions and in Java through interfaces and abstract classes.
Read the full explanation →Who developed the C++ programming language?
- A.Dennis Ritchie
- B.James Gosling
- C.Bjarne Stroustrup
- D.Guido van Rossum
Show answer
Bjarne Stroustrup developed the language at Bell Laboratories, starting it as C with Classes and giving it the name C++ in 1983; it adds classes, inheritance and polymorphism to C while keeping C procedural power, which is why it is called a hybrid language.
Read the full explanation →The Java programming language was developed at Sun Microsystems under the leadership of
- A.Alan Kay
- B.James Gosling
- C.Anders Hejlsberg
- D.Ken Thompson
Show answer
James Gosling and his team at Sun Microsystems developed Java, which was first called Oak and was released under the name Java in 1995; its programs are compiled to bytecode and run on the Java Virtual Machine, which makes them platform independent.
Read the full explanation →In object-oriented programming, the ability of the same function name to work with different sets of parameters is called
- A.Inheritance
- B.Encapsulation
- C.Function overloading
- D.Function overriding
Show answer
Overloading means defining several functions of the same name in the same class with different numbers or types of parameters, so the compiler decides which one to call; because the decision is taken before the program runs, it is called compile-time or static polymorphism.
Read the full explanation →Which statement about a class and an object is correct?
- A.A class is an instance of an object
- B.An object is a blueprint and a class is its instance
- C.A class is a blueprint and an object is its instance
- D.A class and an object both occupy memory in the same way
Show answer
A class only describes the data members and member functions that its objects will have, while an object is created from the class, occupies memory and holds actual values; one class may have any number of objects.
Read the full explanation →The feature by which a new class acquires the properties and behaviour of an existing class is
- A.Inheritance
- B.Polymorphism
- C.Abstraction
- D.Message passing
Show answer
Inheritance lets a derived, child or sub class take the members of a base, parent or super class and add its own, which is the main route to code reuse in object-oriented programming; its forms are single, multiple, multilevel, hierarchical and hybrid.
Read the full explanation →Which special member function is executed automatically when an object of a class is created?
- A.Destructor
- B.Constructor
- C.Friend function
- D.Virtual function
Show answer
A constructor carries the same name as its class, is called automatically the moment an object is created and is normally used to give the data members their initial values; it returns no value at all, not even void, and it can be overloaded.
Read the full explanation →Which of the following languages does NOT support multiple inheritance through classes?
- A.C++
- B.Java
- C.Python
- D.Eiffel
Show answer
Java deliberately leaves out multiple inheritance of classes to avoid the ambiguity that arises when two base classes supply a member of the same name, the problem often called the diamond problem, and it provides interfaces so that a class can still take behaviour from more than one source.
Read the full explanation →In C++, members of a class declared as private can be accessed
- A.From anywhere in the program
- B.Only within the same class
- C.Within the class and its derived classes
- D.Only from the main function
Show answer
Private is the most restricted access specifier and is also the default for a C++ class, so private data members can be read or changed only by the member functions of that class, and by a friend function or friend class if one is declared.
Read the full explanation →Frequently Asked Questions
What are the four basic concepts of object-oriented programming?
Encapsulation, which binds data with the methods acting on it; abstraction, which hides implementation and shows only essentials; inheritance, which lets one class take the features of another; and polymorphism, one name behaving in many forms.
What is the difference between a class and an object?
A class is the blueprint or template that declares data members and member functions, and it does not reserve memory for data members. An object is an instance created from the class; it occupies memory and holds actual values.
What is the difference between function overloading and function overriding?
Overloading uses the same function name with different parameter lists in one class and is resolved by the compiler, so it is static polymorphism. Overriding redefines a base class method in a derived class with the same signature and is resolved while the program runs, so it is dynamic polymorphism.
Which was the first object-oriented programming language?
Simula 67, developed by Ole-Johan Dahl and Kristen Nygaard, which introduced classes, objects and inheritance. Smalltalk, developed under Alan Kay at Xerox PARC, is cited as the first purely object-oriented language.
Why is Java said not to support multiple inheritance?
Java does not let a class extend more than one class, because two base classes could supply a member of the same name and create ambiguity, the diamond problem. A class may implement several interfaces instead, so Java supports multiple inheritance of interfaces but not of classes.
Sources
- Computer Science, Textbook for Class XII — NCERT
- Informatics Practices, Textbook for Class XI — NCERT
- Computer Science and Engineering model curriculum, object-oriented programming course outline — All India Council for Technical Education





