Tuesday, 27 November 2018

Java - Object

Objects are the basic runtime entities in an object oriented system.
  Object is a runtime memory which has the copy of instance members of the class.
  Object can have the memory for instance variables only.
·      A ob = new A();
o        A()- Default constructor
o        new –Memory allocation Operator
Object creation
Object creation can be done in two ways.
·          Memory full state
·          Memory Less State
Memory full state
A ob=new A(); - It is known as object.
ob.get();
Memory less state
A ob; - It is a reference.
ob.get(); 
Here NullPointerException will be raised. Because reference can’t be used to call class members.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.