Search Placementyogi.com
 

OOPS Concept in Java

Getting your OOPS Concepts clear is the first and the most important step towards becoming a Java Programmer.

As the name suggests, "Object Oriented" means everything is revolving around Objects. To understand what Objects mean, Lets start with a simple Question.

What are the components of a computer program?

A computer program has 2 components.

1. Code

2. Data

Data consists of all the variables in a program which can be modified or used. For Example: variables, constants etc

Code are the statements that actually makes use of the Data and manipulate it. For Example, functions, methods, procedures etc

int i=10,j=20,k; // <- Data 
k=i+j;           // <- Code that operated on i j and k

There are two approaches to programming.

  1. Procedure Oriented Programming: The program's revolves around "What to do and how to do it". It consists of statements that execute one by one and preforms a specific task. The focus is on CODE.
  2. Object Oriented Programming:  The program's revolves around "What is being changed". The main focus is on the DATA. There is some DATA and then there are methods which have controlled access to it. We will discuss about "Objects" later in detail. For now, just understand that everything is considered an Object and has certain operations that can be performed on that object based on the type of object. 

A dog is an Object, a book is an Object,a car, a building , everything is an object! and each object has its own properties and we write methods to change these properties.

For Example: A car would have properties like color, model, current_speed. The methods would be accelerate() and stop().

An Object in Java Example Pictorial Representation

Let's say that the color is "white", model is "Honda City" and when it is parked the current_speed is 0.

When accelerate() method is called it increases the current_speed of the car and the stop() method starts decreasng hte speed till the current_speed is back to 0.

 

We will discuss the PILLARS of Object Oriented Programming in the next page.

(There can be other propterties too like seating_capacity, mileage etc. and other methods like change_color(),brake() etc but we have not mentioned them here to avoid complexity)

 

Banner to LogicGuns.com

Hide Page Information

Object Oriented Programming Concepts in Java

Object Oriented Programming in Java is discussed in detail in this tutorial

What do you mean by Object Oriented Programming?

Object Oriented Programming means that everything is considered an object and the whole application is built around Objects

Procedural Programming v/s Object Oriented Programming

In Procedure Oriented Programming statements are executed sequentially to perform an action, the focus is on procedure. In OOPS the man focus is on Data and how it is manipulated.