0% found this document useful (0 votes)
18 views7 pages

Chapter 1

Uploaded by

maheshsudha794
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)
18 views7 pages

Chapter 1

Uploaded by

maheshsudha794
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/ 7

Java programming BCA DEPT

Unit-1
Chapter 1
Fundaments of Object-Oriented Programming
2 Marks:

1.What is Object Oriented Programming?


Ans: Object-Oriented Programming (OOP) is an approach to program
organization and development. It is a new way of organizing and developing
programs. The major objective of object-oriented approach is to eliminate some
of the flaw encountered in the procedural approach. OOP treats data as a critical
element in the program development and does not allow it to flow freely around
the system.

2. Define the terms i) Data Encapsulation ii) Data Abstraction


Ans: The wrapping up of data and methods into a single unit (called class) is
known as encapsulation. The data is not accessible to the outside world and
only those methods, which are wrapped in the class, can access it. Abstraction
refers to the act of representing essential features without including the
background details or explanations. Example, mobile phones

3. What do you mean by data hiding ?


Ans: The data is not accessible to the outside world and only those methods,
which are wrapped in the class, can access it. These methods provide the
interface between the object’s data and the program. This insulation of the data
from direct access by the program is called data hiding.

4. What is Polymorphism? Give example?


Ans: Polymorphism is another important OOP concept. Polymorphism means
the ability to take more than one form. For example, consider the operation of
addition. For 2 numbers, the operation will generate a sum. If the operands are
strings, then the operation would produce a third string by concatenation.

5. What is dynamic binding?


Ans: Binding refers to the linking of a procedure call to the code to be executed
in response to the call. Dynamic binding means that the code associated with a

IMJISC MOODLAKATTE, KUNDAPURA


1
Java programming BCA DEPT

given procedure call is not known until the time of the call at runtime. It is
associated with polymorphism and inheritance

6. Mention any four advantages of OOP?


Ans: OOP offers several benefits to both the program designer and the user.
The principal advantages are:
• Through inheritance, we can eliminate redundant code and extend the use
of existing classes.
• It saves development time and gives higher productivity.
• Data hiding helps the programmer to build secure programs.
• It is possible to have multiple objects to coexist without any interference.
• It is easy to partition the work in a project based on objects.
• Easily upgraded from small to large systems.
• Message passing techniques for communication between objects make
the interface descriptions with external systems much simpler.
• Software complexity can be easily managed

7. Mention any four application areas of OOP


Ans: The promising areas for application of OOP include:
• Real-time systems
• Simulation and modeling
• Object-oriented databases
• Hypertext, hypermedia and expert text
• AI and expert systems
• Neural networks and parallel programming
• Decision support and office automation systems
• CIM/CAD system

Long Answer Questions:


1. Explain various features of OOP.
Ans: The general concepts of OOP which form the heart of Java language
1. Objects and Classes
2. Data abstraction and Encapsulation
3. Inheritance
4. Polymorphism
5. Compile Time and Runtime Mechanisms

IMJISC MOODLAKATTE, KUNDAPURA


2
Java programming BCA DEPT

6. Dynamic Binding
7. Message Communication
Object and Classes
Objects are the basic runtime entities. It represents a person, a place, a bank
account, a table of data or any item. They may also represent user-defined data
types. When a program is executed, the objects interact by sending messages to
one another. For example, ‘customer’ and ‘account’ are 2 objects in a banking
program, then the customer object may send a message to the account object
requesting for the balance. Each object contains data and code. The below
figure shows a notation that is popularly used to represent an object in object-
oriented analysis and design

Object
Person

Name Data

BasicPay

Salary() Methods

Tax()

The entire set of data and code of an object can be made a user-defined data
type using the concept of a class. A class may be thought of as a ‘data type’ and
an object as a ‘variable’ of that data type. Once a class has been defined, awe
can create any number of objects belonging to that class. Each object is
associated with the data of type class with which they are created. A class is
thus a collection of objects of similar type. For example, mango, apple, and
orange are members of the class fruit
Data Abstraction and Encapsulation
The wrapping up of data and methods into a single unit (called class) is known
as encapsulation. The data is not accessible to the outside world and only those
methods, which are wrapped in the class, can access it. These methods provide
the interface between the object’s data and the program. This insulation of the
data from direct access by the program is called data hiding. Encapsulation
makes it possible for objects to be treated like ‘black boxes’, each performing a
specific task without any concern for internal implementation (see below figure)

IMJISC MOODLAKATTE, KUNDAPURA


3
Java programming BCA DEPT

Inheritance
Inheritance is the process by which objects of one class acquire the properties of
another class. Inheritance supports the concept of hierarchical classification. For
Abstraction refers to the act of representing essential features without including
the background details or explanations. Example, mobile phones
example, the bird robin is a part of the class flying bird, which is again a part of
the class bird. It is illustrated in below figure.

In OOP, the concept of inheritance provides the idea of reusability. This means
that we can add additional features to an existing class without modifying it.
This is possible by deriving a new class from the existing one. The new class
will have the combined features of both the classes
Polymorphism
Polymorphism is another important OOP concept. Polymorphism means the
ability to take more than one form. For example, consider the operation of
addition. For 2 numbers, the operation will generate a sum. If the operands are
strings, then the operation would produce a third string by concatenation. The

IMJISC MOODLAKATTE, KUNDAPURA


4
Java programming BCA DEPT

below figure illustrates that a single function name can be used to handle
different number and different types of arguments

Compile Time and Runtime Mechanisms


Compile time may refer to the following
• The operations performed by the compiler
• The pre-runtime assessment of the programs behavior
Runtime is the time period when a syntactically correct program is actually
executed in the computer system
Dynamic Binding
Binding refers to the linking of a procedure call to the code to be executed in
response to the call. Dynamic binding means that the code associated with a
given procedure call is not known until the time of the call at runtime. It is
associated with polymorphism and inheritance
Message Communication
An OOP consists of a set of objects that communicate with each other. The
process of programming in an object-oriented language involves the following
basic steps
1. Creating classes that define objects and their behavior
2. Creating objects from class definitions
3. Establishing communication among objects
Objects communicate with one another by sending and receiving information
much the same way as people pass messages to one another as shown in below
figure.

IMJISC MOODLAKATTE, KUNDAPURA


5
Java programming BCA DEPT

A message for an object is a request for execution of a procedure, and therefore


will invoke a method in the receiving object that generates the desired result, as
shown in below figure

Message
Method()

Sending Object Receiving Object


Message passing involves specifying the name of the object, the name of the
method and the information to be sent. For example: Employee.Salary(name);
Objects have a life cycle. They can be created and destroyed. Communication
with an object is feasible as long as it is alive

2. Write a note on application and benefits of OOP


Ans:
Applications of OOP
The promising areas for application of OOP include:
• Real-time systems
• Simulation and modeling
• Object-oriented databases
• Hypertext, hypermedia and expert text
• AI and expert systems
• Neural networks and parallel programming
• Decision support and office automation systems
• CIM/CAD system

IMJISC MOODLAKATTE, KUNDAPURA


6
Java programming BCA DEPT

OOP offers several benefits to both the program designer and the user.
principal advantages are:
• Through inheritance, we can eliminate redundant code and extend the use
of existing classes.
• It saves development time and gives higher productivity.
• Data hiding helps the programmer to build secure programs.
• It is possible to have multiple objects to coexist without any interference.
• It is easy to partition the work in a project based on objects.
• Easily upgraded from small to large systems.
• Message passing techniques for communication between objects make
the interface descriptions with external systems much simpler.
• Software complexity can be easily managed

IMJISC MOODLAKATTE, KUNDAPURA


7

You might also like