Object and Class in Java

Object in Java

An object has three characteristics

Characteristic Description
State represents data (value) of an object.
behavior represents the behavior (functionality) of an object such as deposit, withdraw etc.
identity Object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. But,it is used internally by the JVM to identify each object uniquely.

Class in Java


class {  
    data member;  
    method;  
}  

Simple Example of Object and Class


class Student1{  
 int id;//data member (also instance variable)  
 String name;//data member(also instance variable)  
  
 public static void main(String args[]){  
  Student1 s1=new Student1();//creating an object of Student  
  System.out.println(s1.id);  
  System.out.println(s1.name);  
 }  
}  

     
Output:0 null

Instance variable in Java

Any Question ?