Classes and Methods

1) Which is used to get the value of the instance variables?

Ans: Dot notation.

2) The new operator creates a single instance named class and returns a

reference to that object.




3) A class is a template for multiple objects with similar features.



Ans: a.

4) What is mean by garbage collection?

Ans: When an object is no longer referred to by any variable, Java automatically

reclaims memory used by that object. This is known as garbage collection.

5) What are methods and how are they defined?

Ans: Methods are functions that operate on instances of classes in which they are defined.Objects can communicate with each other using methods and can call methods in other classes.

Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method.

A method’s signature is a combination of the first three parts mentioned above.

6) What is calling method?

Ans: Calling methods are similar to calling or referring to an instance variable. These methods are accessed using dot notation.

Ex: obj.methodname(param1,param2)

7) Which method is used to determine the class of an object?

Ans: getClass( ) method can be used to find out what class the belongs to. This class is defined in the object class and is available to all objects.

Ref Link contributor :

Permanent link to Java Tutorials / Java Interview Questions: