2 Mark Q & A - UNIT I
2 Mark Q & A - UNIT I
UNIT – I
1. Define object oriented programming?
OOP is an approach that provides a way of modularizing programs by
creating partitioned memory areas for both data and functions that can be used as an
templates for creating copies of such modules on demand.
2. List some features of OOP?
i. Emphasis is on data rather than procedures.
ii. Programs that are divided into what are known as objects.
iii. Follows bottom – up approach in program design.
iv. Functions that operate on the data of an object are tried together in
the data structure.
3. Define Class?
A Class is a collection of objects of similar type.
The classes are user-defined data types and behave like built-in types
of a programming language.
A class is a way to bind the data and its associated functions together.
A class is a user-defined data type with a template that serves to define
its properties.
A class is a blueprint that defines the variables & the methods
common to all objects of a certain kind.
4. What do you mean by object?
Objects are basic run-time entities in an object-oriented system. They may represent
a person, a place, a bank account, a table of data or any item that the program has to handle.
Each object has the data and code to manipulate the data and theses objects interact with each
other.
5. What is meant by Encapsulation?
The wrapping up of data and function into a single unit(class) is known as
Encapsulation.
6. What do you mean by Data abstraction?
Abstraction refers to the act of representation of essential features without
including the background details or explanations. Classes use the concept of
abstraction
& are defined as a list of abstraction attributes such as size, weight & cost &
functions to operate on these attributes.
7. What do you mean by inheritance?
Inheritance is the process by which objects of one class acquire the
properties of objects of another class.
8. What do you mean by reusability?
The process of adding additional features to an existing class without
modifying it is known as „Reusability‟. The reusability is achieved through
inheritance. This is possible by deriving a new class from an existing class. The new
class will have the combined features of both the classes.
9. Define polymorphism?
Polymorphism means the ability to take more than one form. For example, an
operation may exhibit different behavior in different instances. The behavior
depends upon the types of data used in the operation.
At runtime, when it is known what class objects are under consideration, the
appropriate version of the function is invoked. Since the function is linked with a
particular class much later after its compilation, this process is termed as „late
binding‟. It is also known as dynamic binding because the selection of the
appropriate function is done dynamically at run time. This runtime polymorphism can
be achieved by the use of pointers to objects and virtual functions.
12. What do you mean by message passing?
Objects communicate with one another by sending and receiving information.
A message for an object is a request for execution of a procedure, and therefore will
invoke a function in the receiving object that generates the desired result. Message
passing involves specifying the name of the object, the name of the function and the
information to be sent.
13. List out the benefits of OOPS.
Through inheritance, we can eliminate redundant code and extend the
use of existing classes.
The principle of data hiding helps the programmer to build secure
programs.
It is possible to have multiple instances of an object to co-exist without
any interference.
Object oriented systems can be easily upgraded from small to large
systems.
Software complexity can be easily managed.
20. What is array? How do you declare Single dimensional array in C++?
An array is a collection of variable of the same type that are referred to through a
common name. A specific element in an array is accessed by an index.
General form for declaring one dimensional
array: type var-name[size];
Here type declares the base type of the array and size defines how many elements
the array will hold. Example: int x[10]; // elements are x[0] ,x[1] ……..x[9]