what is an object and how do you allocate memory to it?

Answer Posted / tulasi

Object is an instance of the class.There are two ways by
which a new object is created.

1.using new operator.
example:
classname objectname=new classname;
This allocates the memory to objectname.

This can be classname objectname by which null values are
set to the objectname and not the values as in the class.

2.without using new operator.
Declare the variables as static and also methods used as
static and by using the keyword static we can create an
instance of the class.
Thus, we use public static void main(String args[])in main
program where theres no need to create a class and also
instance of class using new operator.

Is This Answer Correct ?    8 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Implement 2 stacks with just 1 array. The stack routines must not indicate overflow unless every slot in array is used.

1047


Why are generics used?

713


Why string is immutable with example?

715


What is the difference between exception and error in java?

695


I want my class to be developed in such a way that no other class (even derived class) can create its objects. Define how can I do so?

889


What does nullpointerexception mean?

843


What is default size of arraylist in java?

758


Explain the significance of class loaders in bootstrap?

702


Explain the importance of finally block in java?

723


Is java still relevant?

712


explain autoboxing in java?

762


Differece between class and generic class?

769


What is keyword in oop?

725


What is externalizable interface?

802


Why char array is preferred over string for storing password?

816