Java Object

What is  java Object ?

  • Object in java is  real time entity which have state and behavior.
  • State defines characteristic of object and behavior defines functionality of object
  • An object is a copy of class, each time we create an object a copy of class will be created
  •  In the World of java each and everything is Object.

How to Create Object in Java ?
Let’s consider Notebook as object and understand the state and behavior
of Notebook.

class Notebook


//characteristic of notebook

String brand;
int pages;
double price;

//functionality of notebook

void open()
System.out.println(“open the book”);
void read()
System.out.println(“reading book”);
void close()
System.out.println(“closing book”);

//method to get details of notebook

void bookdetail()

System.out.println(“brand name: “+brand);

System.out.println(“number of pages: “+pages);

System.out.println(“price of notebook: “+price);


public class ObjectExample {

public static void main(String[] args)
//creating instance of notebbok
Notebook mbook=new Notebook();

mbook.brand=”class mate”;

mbook.bookdetail();//calling function to get notebook detail


// creating second instance of notebook

Notebook mbook1=new Notebook();


mbook1.bookdetail();//calling function to get notebook detail



brand name: camel
number of pages: 230
price of notebook: 20.0

Leave a Reply