OOP Using C++ – Object Oriented Programming Concepts based Question And Answers

Programming In C++ Long Questions and AnswersHere in this section of Programming In C++ Long Questions and Answers,We have listed out some of the important Long Questions with Answers which will help students to answer it correctly in their University Written Exam.

 

Lists of Long Descriptive type Questions and Answers

  • 1. What is Object Oriented Programming? Differentiate procedure oriented and object oriented programming language. OR List out characteristics of POP and Object Oriented Programming(OOP)
  • 2. Explain Basic Concepts of Object Oriented Programming(OOP). OR Explain Following terms.
  • 3. List out benefits of Object Oriented Programming(OOP)
  • 4. List out Applications of Object Oriented Programming(OOP).

 

Question – 1. What is Object Oriented Programming? Differentiate procedure oriented and object oriented programming language. OR List out characteristics of POP and OOP

Object Oriented Programming is programming paradigm that represents concepts as objects that has data fields and associated procedures known as methods.

 

Procedure Oriented Programming (POP) Object Oriented Programming (OOP)
1. Emphasis is on doing things not on data, means it is function driven 1. Emphasis is on data rather than procedure, means object driven
2. Main focus is on the function and procedures that operate on data 2. Main focus is on the data that is being operated
3. Top Down approach in program design 3. Bottom Up approach in program design
4. Large programs are divided into smaller programs known as functions 4. Large programs are divided into classes and objects
5. Most of the functions share global data 5 5. Data is tied together with function in the data structure
6. Data moves openly in the system from one function to another function 6. Data is hidden and cannot be accessed by external functions
7. Adding of data and function is difficult 7. Adding of data and function is easy
8. We cannot declare namespace directly 8. We can use name space directly, Ex: using namespace std;
9. Concepts like inheritance, polymorphism, data encapsulation, abstraction, access specifiers are not available. 9. Concepts like inheritance, polymorphism, data encapsulation, abstraction, access specifiers are available and can be used easily
10. Examples: C, Fortran, Pascal, etc… 10. Examples: C++, Java, C#, etc…

 

Question – 2. Explain Basic Concepts of OOP. OR Explain Following terms.

Various concepts present in OOP to make it more powerful, secure, reliable and easy

Object

  • An object is an instance of a class.
  • An object means anything from real world like as person, computer, bench etc…
  • Every object has at least one unique identity.
  • An object is a component of a program that knows how to interact with other pieces of the program.
  • An object is the variable of the type class.
  • For example, If water is class then river is object.

Class

  • A class is a template that specifies the attributes and behavior of things or objects.
  • A class is a blueprint or prototype from which objects are created.
  • A class is the implementation of an abstract data type (ADT).
  • It defines attributes and methods.

 

Example:

class employee // Class

{

  char name[10]; // Data member

  int id; // Data member

  public:

  void getdata() // Member function

  {

  cout<<”enter name and id of employee: ”;

  cin>>name>>id;

  }

}a; // Object Declaration
  • In above example class employee is created and ‘a’ is object of this class.
  • Object declaration can be also done in main() function as follows:
int main()

{

  employee a;

}

 



 
Data Abstraction

Just represent essential features without including the background details.

They encapsulate all the essential properties of the objects that are to be created.

The attributes are sometimes called ‘Data members’ because they hold information.

the functions that operate on these data are sometimes called ‘methods’ or ‘member functions’.

It is used to implement in class to provide data security.

 

Encapsulation

Wrapping up of a data and functions into single unit is known as encapsulation.

In C++ the data is not accessible to the outside world.

Only those functions can access it which is wrapped together within single unit.

 

Inheritance

Inheritance is the process, by which class can acquire the properties and methods of another class.

The mechanism of deriving a new class from an old class is called inheritance.

The new class is called derived class and old class is called base class.

The derived class may have all the features of the base class.

Programmer can add new features to the derived class.

For example, Student is a base class and Result is derived class.

 

Polymorphism

A Greek word Polymorphism means the ability to take more than one form.

Polymorphism allows a single name to be used for more than one related purpose.

The concept of polymorphism is characterized by the idea of ‘one interface, multiple methods’,

That means using a generic interface for a group of related activities.

The advantage of polymorphism is that it helps to reduce complexity by allowing one interface to specify a

general class of action’. It is the compiler’s job to select the specific action as it applies to each situation.

It means ability of operators and functions to act differently in different situations.

 

Example:

int total(int, int);

int total(int, int, float);

 

Static Binding

Static Binding defines the properties of the variables at compile time. Therefore they can’t be changed.

Dynamic Binding

Dynamic Binding means linking of procedure call to the code to be executed in response to the call.

It is also known as late binding, because It will not bind the code until the time of call at run time. In

other words properties of the variables are determined at runtimes.

It is associated with polymorphism and inheritance.

 

Message Passing

A program contains set of object that communicates with each other.

Basic steps to communicate

  1. Creating classes that define objects and their behavior.
  2. Creating objects from class definition
  3. Establishing communication among objects.

 

Message passing involves the object name, function name and the information to be sent.

Example: employee.salary(name);

In above statement employee is an object. salary is message, and name isinformation to be sent.

 

Question – 3. List out benefits of OOP

We can eliminate redundant code though inheritance.

Saving development time and cost by using existing module.

Build secure program by data hiding.

It is easy to partition the work in a project based on object.

Data centered design approach captures more details of a programming model.

It can be easily upgraded from small to large system.

It is easy to map objects in the problem domain to those in the program.

Through message passing interface between objects makes simpler description with external system.

Software complexity can be easily managed.

 

 

Question – 4. List out Applications of OOP.

Applications of OOP technology has gained importance in almost all areas of computing including real-time

business systems. Some of the examples are as follows:

  1. Real-time systems
  2. Simulation and modeling
  3. Object oriented database
  4. Artificial intelligence and expert systems
  5. Neural networks and parallel programming
  6. Decision support and office automation
  7. CIM/CAM/CAD systems.
  8. Distributed/Parallel/Heterogeneous computing
  9. Data warehouse and Data mining/Web mining

 
You may be interested in:
Programming In C MCQs
Programming In C++ MCQs
Programming In C Tutorials