You are on page 1of 10

Unit 1

Object Oriented Programming

1.1. Software Evolution.


1.2. Basic Concept of Object Oriented Programming
 Procedure Oriented Programming
 Object Oriented Programming
 Procedure oriented versus Object Oriented
Programming
1.3. Elements of Object Oriented Programming
 Class and Object
 Inheritance
 Polymorphism
 Dynamic Binding
 Message Passing
1.4. Object Oriented Languages
1.5. Advantages and Dis advantages of OOP
1. What do you understand by computer program?
A program is a set of instructions that, when executed, causes the
computer to behave in predetermined manner.

2. Explain the various types of programming languages in brief.

There are mainly two types of programming language and those are:
 Low level language: -Low level language is a programming
language in which each statement or instruction is directly translated
into a single machine code. It is machine dependent.

 High level language: - A high level language is a programming


language that is more user friendly, to some extent platform
independent and abstracts from low level computer processor
operation such as memory access. Some example of high level
languages are: - C, C++, Java, VB etc.

3. What is Procedure Oriented Programming?


Procedure oriented programming is a standard programming
approach, used in traditional computer language such as, C, Pascal,
FORTAIN and BASIC. In this programming language can be thought as
set of task and sub task. Any complex task is broken down into a set of
self-contained, sufficient small and easily understandable components (i.e.
functions). This programming paradigm uses top-down approach in
program design.

4. What are the main characteristics of Procedure Oriented


Programming?
The main characteristics of procedure oriented programming are as
follows.
 Emphasis is on doing things (algorithm).
 Large program is divided into smaller program also known as
functions.
 Most of the functions share global data/ variables.
 Data are more openly around the system from functions to function.
 Functions transform data from one to another.
 Uses top-down approach in program design.

5. What are the advantages and disadvantages of Procedure Oriented


Programming?
The advantages of POP are as follows.
 It is written in a step-by step using function.
 It is easy to maintain, as each function can be debugged in a
isolated form.
 It is written for very specific purpose, the code is extremely
efficient and high-performance.
The disadvantages and limitation of POP are as follows.
 Procedural coding is very difficult to maintain for larger code.
 Code reusability is not present in POP.
 Procedural code is difficult to relate with real world objects.
 It is difficult to hide information to unauthorized external user
which is easy in OOP.
 Importance is given to operation on data rather than on the data
security.

6. What is Object-Oriented Programming (OOP)?


Object oriented programming is a model of programming language
which focus on the use of class and objects for problem solution. It is more
concerned with data and less concerned with logic. It uses bottom-up
approach in program design.

7. What are the main characteristics of Object Oriented Programming?


The characteristics of object oriented programming are:
 Emphasis is done on data rather than on procedure or algorithm.
 Program are divided into small module known as class. Functions
and data are tied together in an object. The binding of functions with
data is known as encapsulation.
 Data can be hidden using access specifiers like public, private and
protected and can’t be accessed in internal environment easily.
 Object communicate with each other, by sending message and
receiving responses.
 New data and functions can be added easily whenever necessary.

8. What are the advantages of OOPs?


The advantages of OOPS are as follows.
 It provides a clear modular structure for programs.
 It makes easy to maintain and modify existing code as new
objects can be created with small differences to existing ones.
 It provides a good framework for code libraries where supplied
software components can be easily adapted and modified by the
programmer.

9. What are the Disadvantages of OOPs?


The disadvantages of OOPs are: -
 More Size: - It is much larger than other programming
languages and takes more computing power and memory.
 Speed: - It is high level concept so it takes more time to
execute.
 Extra Overhead: - It requires a lots of work to be done.
Specially, more planning, design and other documents is
required before a single piece of code is written.

 Need specialize knowledge: - The developers must have


extra knowledge about concept and features of OOPS and
thus it increases burden on part of the developers.
 Difficult to debug: - The message passing between many
objects of complex applications may be difficult to trace and
debug.

10.What are the applications of OOPs?


The applications of OOPs are: -
 Real time Systems: - It is a dynamic system, means the system
that changes every movement base on input to the system.
 Simulation and Modeling: - It is a process of creating analyzing a
prototype of physical model to predict its performance in real world.
 Hypertext and Hypermedia: - It is easy to represent real
object with the concept of OOPs object which is easy to use for
hypertext and hypermedia.
 Decision support system, AI and Expert System: - It uses
real time system which are to advance and complex system.
 CAM/CAE/CAD System: - The concept of OOP is widely
being used to make various tools or system to use in the area
of Computer Aid Manufacturing (CAM), Computer Aid
Engineering (CAE) and Computer Aid Design(CAD).
 Office Automation System: - It is just a type of real system
and the embedded system make it easy to use OOP for
automated system.

 Object Oriented Database: - It is a Database management


system (DBMS) that supports the modeling and creation of
data as objects.
 User Interface: - We can design user interface such as
window, menu toolbar using OOPS.

11.What are the concepts of OOP?


The concepts of OOP are:
 Classes
 Objects
 Inheritance
 Polymorphism
 Encapsulation
 Data Abstraction
 Data hiding
 Message passing
12.What is object?
This is the basic unit of object oriented programming. That is both data and
function that operate on data are bundled as a unit called as object.

13.What is class?
Class is a collection or group of similar objects that have same
properties common behavior and relationships.

14.What is Encapsulation?
Encapsulation is the process that allows selective hiding data and
functions in a class.

15.What is Polymorphism?
Polymorphism enables the same function to behave differently on
different classes.

16.What is data abstraction?


Data abstraction is the process of identifying properties and methods
related to a particular entity as relevant to the application.

17.What is inheritance?
Inheritance is the property that allows the reuse of an existing class to
build a new class. The principle in this sort of division is that each subclass
shares common properties with the class from which it is derived.

18. What is Encapsulation?


Encapsulation is an ability to bind (package) function and data
together in a place and hide (or prevent) the data from unauthorized use
from other parts of the program.

19. Define message passing?


An object can send or receive message/information from/to another
object. A message for an object is request for execution of a procedure
and therefore will invoke function in receiving object that generates the
desire result.
The message passing involves name of object, name of function
(message) and information to be send.
Syntax: -
object.FunctionName(parameters)
Example: -
student.Getmarks(10);

18. Write the difference between POP and OOP.


S.No POP OOP
.
1 POP emphasizes on OOP emphasizes on data rather
algorithms (procedure) than procedure.
2. Large programs are Programs are divided into
divided into smaller objects.
programs known as
functions.
3. They don't have facility to They have facility to hide data
hide data. from outside world.
4. Function can transfer data Objects can communication with
from one function to other each other using functions.
using parameters.
5. It uses top-down approach It uses bottom-up approach for
for program design. program design.
6. Examples : COBOL etc. Examples : C++, Java etc.

19. Write the features of OOP?


The features of OOP are:
 Programs are divided into objects and modules.
 Data and functions are encapsulated into a single entity.
 Objects may communicate with each other through functions.
 New data and functions can be easily added whenever necessary.
 Follows bottom up approach in program design.
 In OOPs we create classes which have power of reusability.

20. Write some examples of OOP languages.


There are various popular programming languages that support
features of object oriented programming languages and some of them are:
-
 Java
 C#.net
 VB.net
 C++
 Smalltalk
 PHP
 Perl
 ProLog++

21. What is the full form of OOP?


The full form of OOP is Object Oriented Programming.
21. How can you write comment in C++?
Multiline comment: The text to be written within comment starts with
/* and ends with */
Single line comment: The text to be commented is written after//. It
supports only single line.

22. Write a C++ program to display message “welcome to C++ !!” in


screen.
#include<iostream.h>
void main()
{
cout<<”Welcome to C++!!”;
}
 Write a program in C++ to add two numbers and display the sum of these
numbers.
#include<iostream>
using namespace std;
int main ()
{
int a,b,c;
a=10;
b=30;
c=a+b;
cout <<"the sum of" <<a<< "and" <<b<< "is:"<<c;
return 0;
}
 Write a program to use end and specify new line.
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
cout<<"hello ram!!!"<<endl<<"how are you?";
return 0;
};

24.What is Inline function?


In the C and C++ programming languages, an inline function is one
qualified with the keyword inline; this serves two purposes.
Firstly, it serves as a compiler directive, which suggests (but does not
require) that the compiler substitute the body of the function inline by
performing inline expansion,
The second purpose of inline is to change linkage behavior; the details of
this are complicated.

25.What is operator overloading?


In programming, operator overloading—less commonly known as operator
ad hoc polymorphism—is a specific case of polymorphism, where different
operators have different implementations depending on their arguments.
Operator overloading is generally defined by the language, the
programmer, or both.

26.Different between method overriding and  method overloading?


In Overriding methods it will create two or more methods with same name
and same parameter in different classes.

while Overloading it will create more than one method with same name but
different parameter in same class.

You might also like