Womens College Java 2018 (1) - 1
Womens College Java 2018 (1) - 1
Womens College Java 2018 (1) - 1
A. The major Objective of Object – Oriented approach is to eliminate some of the drawbacks in the
Procedural approach. OOP treats data as critical element in the program development, does not
allow to it flow freely around the system. OOPs allows us to decompose a problem into a number of
entities called Objects and then build data and functions. The combination of data and methods
make up an object.
The data of an object can be accessed only by the methods associated with that object. Some of
the features associated with that object. Some of the features of the Object Oriented Paradigm are:
Emphasis is on data rather than procedure
Programs are divided into what are known as objects
Data Structures are designed such that they characterized the objects
Methods that operate on the data of an object are tied together in the data structure
Data is hidden and cannot be accessed by external functions
Objects may communicate with each other through methods
New data and methods can be easily added whenever necessary
Follows bottom-up approach in program design.
3) Explain about Object – Oriented Programming (or) Explain about Features of OOPs (or) Explain
about basic Concepts of OOPs.
A) Object – Oriented Programming is a programming method that combines data and instructions into a self-sufficient
“object”. In Object Oriented Program, the design represented by Objects.
Object:
Objects are Basic entities in an Object Oriented System
Each Object is denoted by a name. Every Object has 2 Characteristics
1) State 2) Behaviour
For example “Foodball ” is an object which has “State such as Color and Size” and it has
“Behaviour Such as Bounce “
In Programming approach this State is represented by using “Variables or Fields”
Where as Behaviour is represented by using “Methods”
The Variables within the object represents everything about the Object(State)
Methods represents “How an Object is used”(Behavior)
Class:
Class is blueprint that defines the variables and methods common to all objects of certain kind
Class is a collection of objects of a Similar type
Once a Class is defined any number of objects can be created to that class
Message Passing
A single object by itself may not be very useful.
An application contains many objects.
One object interacts with another object by invoking methods on that object. It is also referred to as Method
Invocation. See the diagram below.
Data Abstraction:
Data Abstraction refers to, shows only essential information to the Outside world and Hiding their Background
Details
That means to represent the needed information in program without presenting the details
For Example real life example TV, which we can turn on and off, change the channel..etc. But we don’t know the
internal details but we operate it without knowing the internal details
That means the manufacturer of TV, hides the Internal Details for the sake of Security
In Java, it is done by the Concept of Interfaces and Abstract Classes
Encapsulation:
Encapsulation is the process of Binding or Wrapping Data and Methods together into a Single Unit
Encapsulation enables Data hiding, hiding the irrelevant information from the users of a Class by using Accessing
Specifiers called public, protected, private
For Example: Capsule is wrapped with different medicines
Inheritance:
Inheritance is a property by which the new classes are created using the old Classes
In Other Words the new Classes can be developed using some of the properties of old Classes
It is the Concept of Reusability
Here “Old Classes” referred as “Super Class or Parent Class or Base Class”
“New Classes” referred as “Sub Class or Child Class or Derived Class”
For Example: Here in the above example “Mobile” is the “Super Class” where as “Samsung,Nokia,Iphone” are
“Sub Class”. “Sub-Class” uses the common Properties from “Super-Class”
Polymorphism:
Polymorphism means “One Interface, multiple methods”
That means “It is possible to design a Generic Interface to a group of related Activities”
The behavior type of data used in the Operation
It reduces the Complexity by allowing the same interface to used to General Class of action
For Example: the method Clean is used to Clean a Dish object, One that Cleans a “Car Object” and One that
cleans the “Vegetable Object”