100% found this document useful (2 votes)
376 views

2 Mark Q & A - UNIT I

Object oriented programming (OOP) is an approach that divides programs into objects. Some key features of OOP include an emphasis on data over procedures and dividing programs into objects. A class defines common properties and methods for objects of a certain kind. Objects are run-time entities that represent things that a program needs to handle. Encapsulation wraps data and functions into a single unit, while abstraction represents essential features without background details. Inheritance allows objects to acquire properties from other classes. Polymorphism means an operation can take different forms depending on the types of data used.

Uploaded by

padmavathi V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
376 views

2 Mark Q & A - UNIT I

Object oriented programming (OOP) is an approach that divides programs into objects. Some key features of OOP include an emphasis on data over procedures and dividing programs into objects. A class defines common properties and methods for objects of a certain kind. Objects are run-time entities that represent things that a program needs to handle. Encapsulation wraps data and functions into a single unit, while abstraction represents essential features without background details. Inheritance allows objects to acquire properties from other classes. Polymorphism means an operation can take different forms depending on the types of data used.

Uploaded by

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

CS8392-OBJECT ORIENTED PROGRAMMING

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.

Example: Consider the operation of addition.


For two numbers, the operation will generate a sum.
For two strings, the operation will generate a concatenation.
 There are two types of polymorphism: Compile time
polymorphism and Run time polymorphism
10. Define Compile time polymorphism / Early Binding / static Binding
Compile time polymorphism is implemented by using the overloaded
functions and overloaded operators.
The overloaded operators or functions are selected for invokation by matching
arguments both by type and number. This information is known to the compiler at the
compile time therefore the compiler is able to select the appropriate function for a
particular function call at the compile time itself. This is called as „Early Binding‟ or
„Static Binding‟ or „Static Linking‟ or „Compile time polymorphism‟. Early binding
simply means an object is bound to its function call at the compile time.

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.

14. List out the applications of OOPS.


 Real time systems
 Simulation and modeling
 Object oriented data bases
 AI and expert systems
 Neural networks and Parallel programming
 Decision support and Office automation systems
 CAD/CAM systems
15. What is an expression?
An expression is a combination of operators, constants and variables arranged
as per rules of the language. It may include function calls which return values.
16. Define keywords?
Keywords are explicitly reserved identifiers and cannot be used as names for
the program variables or other user defined program elements.

17. How does a main() function in C++ differ from main() in C?


In C++, main() returns an integer type value to the operating system but in C ,
main() returns nothing to operating system by default.
18. What is formal parameter?
If a function is to use arguments , it must declare variables that will
accept the values of the arguments. These variables are called the formal
parameters of the function.
Example : int max(int a , int b) // Variables a and b are formal
parameters { if(a>b) return a; return b; }
19. What is global variable?
Global variables are known throughout the program and may be used by any
piece of code. Also, they will hold their value throughout the program‟s
execution.

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]

21. What is two dimensional array?


It is an array of one dimensional arrays. It has two
subscripts. General form for declaring two dimensional
array:
Data type var-name [size1][size2];
Here size1 refers row index and size2 refers to column index. The number of
elements in the array is size1*size2.
Example:
int x[5][10];
Here x is the two dimensional array having 5 rows and 10 elements in each
row. Number of elements in the array is 5*10=50 elements.

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