Saturday 24 November 2012

what is an object in java?

Ques: what is an object in java?
Ans :An object is an instance of a class. The relationship is such that many objects can be created using one class. Each object has its own data but its underlying structure (i.e., the type of data it stores, its behaviors) are defined by the class

Example:

consider we have a class Hello.java.

public class Hello
{
          }

to create an object for this class is:
 Hello helloObject = new Hello();

Here the helloObject is the object for that class.


No comments:

Post a Comment