Let's learn java programming language with easy steps

Friday, 13 January 2017


 OOPS (Object Oriented Programming System)

Object-Oriented Programming is a programming concept or paradigm used in several modern programming languages like C++, java, etc. The object-oriented programming language directly represents real-life objects like car, bus, table, fan, laptop, customer, account, etc. Before object-oriented programming programs were viewed as procedures that accepted data and produced output.

Object-oriented programming is used to design program using classes and objects. It simplifies the software development and maintenance.

Simula is the first object-oriented programming language.

Truly object-oriented programming: A language in which everything is represented in the form of objects that is known as the truly object-oriented programming language. 

👉: In java, everything is represented in the form of object except primitive data types.

Concepts of OOPS

OOPS provides some concepts, these are 
  1. Object
  2. class
  3. Polymorphism
  4. Inheritance
  5. Encapsulation
  6. Abstraction 


An object is something which has its own identity and can be easily compared to real-world objects like chair, laptop, bed, pen, bike, pencil, all these are objects. Object means real-world entity. An object contains state and behaviors. An object can be physical and logical (tangible and intangible) e.g tangible objects - pen, table, pencil and intangible object - banking system. But the class can be logical entity only.


An Object in java has 3 characteristics   

  • State: states represent state(data) of an object.
  • Behavior: represents the behavior(functionality) of an object.
  • Identity: object identity is typically implemented via unique ID. The value of the ID is not visible to the external users, but it is used internally by the JVM to identify each object uniquely.

For example: 

A dog has states - name, color, height etc.

and behaviors is - wagging the tail, eating, barking, running etc.

An object is an instance of a class because objects are created from a class.

The state of an object is the properties of the object at the particular time and behavior is the function, It will perform. The behavior of an object is usually described using methods and these methods will be part of the object itself.


Objects are grouped into a class. A class can be defined as a group of objects that have common properties. A class can be considered as the blueprint or template of definition for an object. A class describes the properties and behaviors of that objects.

A class in java can contain:

  • data member or field
  • member function or method
  • constructor
  • nested class
  • interface
  • block
Syntax to declare a class

class  Class_Name
data member;

Instance Variable in Java

An instance variables is a variable which is created inside a class but outside the method is known as the instance variable. Instance variable get memory at runtime when an object(instance) is created. That why, it is known as the instance variable.

Method in java

A method in java is like a function, which is used to expose the behavior of an object.

For example:

class MethodDeclareExample
void run()


  • Here 'void' is return type, Which does not return any value.
  • run() is method name.

new Keyword in Java 

  • A new keyword is used to allocate memory at runtime.
  • A new keyword is used to create an object of a class.
For example;

Suppose there is Student class

Student s = new Student();

A class with data member(instance variable) and method(member function) and creating an object by new keyword. Let 's take an example

class Employees
int a;//data member(or instance variable)
double d;//data member(or instance variable)
public static void main(String []args)
Employees e = new Employees();//creating object by new keyword

output: 0


printing default values or object values.

We will learn in details next chapters constructor, interface, block, nested class.

1 comment:

Facebook Page Likes

Follow javatutorial95 on Google+

Follow javatutorial95 on twitter

Popular Posts

Get Updates By Email