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
How infinite loop is declared?
Explain tree set and its features?
What is an object in java and how is it created?
How do you convert string to int in java?
Tell me the Importent classes in net package?
What is a nullable field?
What languages are pass by reference?
Under what conditions is an object’s finalize() method invoked by the garbage collector?
How many types of constructors are used in java?
What is a lightweight component?
What class allows you to read objects directly from a stream?
how many types of Inheritance?
What is data type in computer?
Can we define a package statement after the import statement in java?
What is the use of protected in java?