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
Explain the term virtual machine?
What are invisible components?.
How many bits is a double?
Which package has light weight components in java programming?
How to check if a list is sorted in java?
In java, what is the difference between method overloading and method overriding?
Can classes declared using the abstract keyword cab be instantiated?
What is the use of put method?
What do you mean by hashing?
What is command line argument
What is the difference between ArrayList and Vector? which one is better in Java
What is constant in programming?
What comes to mind when someone mentions a shallow copy in java?
What is return null in java?
When do I need to use reflection feature in java?