JAVA CLASSES

CLASSES

—An object is an instance of a class.
—A class is a template or blueprint from which objects are created.
—An object is a real-world entity.
—An object is a runtime entity.
—The object is an entity which has state and behavior.
—The object is an instance of a class.
CLASS DECLARATION
Syntax to declare a class:
class <class_name>
{  
    field;  
    method;  
}  
INSTANCE VARIABLE IN JAVA
—A variable which is created inside the class but outside the method is known as an instance variable.
— Instance variable doesn't get memory at compile time.
— It gets memory at runtime
—when an object or instance is created.
— That is why it is known as an instance variable.
NEW OPERATOR
—The new keyword is used to allocate memory at runtime.
— All objects get memory in Heap memory area.
OBJECT CREATING IN NEW KEY WORD
public class obj
{
  public void disp()
  {
  System.out.println("method calling");
  }
  public static void main(String args[ ])
  {
  obj a=new obj();
  a.disp();
  }
}
   

Comments

Popular posts from this blog

UNIT II---WORKING WITH ARRAYS AND FUNCTIONS

CHARACTERISTICS OF JAVA

JAVA ARRAY