0% found this document useful (0 votes)
4 views2 pages

GP_OOPS_C++_Interview_Questions

The document outlines key concepts of Object-Oriented Programming (OOP), including its advantages like clarity, simplicity, and code reusability, as well as its main features: inheritance, encapsulation, polymorphism, and data abstraction. It also contrasts constructors and methods, and explains the differences between classes and structures, and between classes and objects. Additionally, it mentions some disadvantages of OOP, such as the need for planning and potential high memory consumption.

Uploaded by

kumhardevraj357
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

GP_OOPS_C++_Interview_Questions

The document outlines key concepts of Object-Oriented Programming (OOP), including its advantages like clarity, simplicity, and code reusability, as well as its main features: inheritance, encapsulation, polymorphism, and data abstraction. It also contrasts constructors and methods, and explains the differences between classes and structures, and between classes and objects. Additionally, it mentions some disadvantages of OOP, such as the need for planning and potential high memory consumption.

Uploaded by

kumhardevraj357
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Interview Questions

1. Why do we use OOPs?


❖ It gives clarity in programming and allows simplicity in solving complex
problems.
❖ Data and code are bound together by encapsulation.
❖ Code can be reused, and it reduces redundancy.
❖ It also helps to hide unnecessary details with the help of Data
Abstraction.
❖ Problems can be divided into subparts.
❖ It increases the readability, understandability, and maintainability of
the code.
2. What are the differences between the constructor and the method?

Constructor Method

It is a block of code that initializes a It is a group of statements that can


newly created object. be called at any point in the
program using its name to perform
a specific task.

It has the same name as the class It should have a different name than
name. the class name.

It has no return type. It needs a valid return type if it


returns a value; otherwise void.

It is called implicitly at the time of It is called explicitly by the


object creation programmer by making a method
call

If a constructor is not present, a In the case of a method, no default


default constructor is provided by method is provided.
Java

1
3. What are the main features of OOPs?
❖ Inheritance
❖ Encapsulation
❖ Polymorphism
❖ Data Abstraction
4. The disadvantage of OOPs?
❖ Requires pre-work and proper planning.
❖ In certain scenarios, programs can consume a large amount of memory.
❖ Not suitable for a small problem.
❖ Proper documentation is required for later use.
5. What is the difference between class and structure?
Class: User-defined blueprint from which objects are created. It consists of
methods or sets of instructions that are to be performed on the objects.
Structure: A structure is basically a user-defined collection of variables of
different data types.

6. What is the difference between a class and an object?

Class Object

Class is the blueprint of an object. It


An object is an instance of the class.
is used to create objects.

No memory is allocated when a class Memory is allocated as soon as an


is declared. object is created.

An object is a real-world entity such


A class is a group of similar objects.
as a book, car, etc.

Class is a logical entity. An object is a physical entity.

Objects can be created many times


A class can only be declared once.
as per requirement.

Objects of the class car can be BMW,


An example of class can be a car.
Mercedes, Ferrari, etc.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy