Java Operators-Classes and Methods-interview-questions1
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.
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. hudihudi.com
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.
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 : http://www.hudihudi.com/placement/java/java14.htm
Permanent link to Java Tutorials / Java Interview Questions: http://www.freshersinterviewquestions.com/java-operators-interview-questions1/