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
What is contractor means and methods?
What is the diffrence between inner class and nested class?
Why string is immutable with example?
In the below example, what will be the output?
What is the relationship between clipping and repainting under awt?
What is join () in java?
What is procedure overloading?
Where import statement is used in a java program?
What is the current version of java?
Is it possible to specify multiple jndi names when deploying an ejb?
What is package private scope in java?
What is method overloading in java ?
What is the purpose of finalization in java programming?
What is a line break example?
What is struts in java?