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

How infinite loop is declared?

539


Explain tree set and its features?

599


What is an object in java and how is it created?

591


How do you convert string to int in java?

562


Tell me the Importent classes in net package?

1582






What is a nullable field?

581


What languages are pass by reference?

540


Under what conditions is an object’s finalize() method invoked by the garbage collector?

577


How many types of constructors are used in java?

541


What is a lightweight component?

596


What class allows you to read objects directly from a stream?

871


how many types of Inheritance?

654


What is data type in computer?

521


Can we define a package statement after the import statement in java?

582


What is the use of protected in java?

536