Search Suggest

Core Java - Interview Questions and Answers

11. Types of Constructors ?

Default Constructor,Parameterized Constructor,Copy Constructors
Garbage collector takes the responsibility releasing the memory of object implicitly.

12. Explain about Static ?

When a member is declared as static it can be accessed before any objects of its class are created and without any reference to any object.
these are global variables, no copy of these variables can be made.

static can also be declared for methods. and cannot refer to this or super.

13. what is downcasting ?

Doing a cast from a base class to a more specific class. The cast does not convert the object, just asserts it actually is a more specific extended object.

E.g.  Dalamatian d = (Dalmatian) aDog; 
Most people will stare blankly at you if you use the word downcast. Just use cast.

14. What are identifiers and literals ?

Identifiers are the variables that are declared under particular datatype.
Literals are the values assigned to the Identifiers.

15. What is Typed language ?

This means that the variables are at first must be declared by a particular datatype whereas this is not the case with javascript.

16. Scope and lifetime of variables ?

scope of variables is only to that particular block
lifetime will be till the block ends.
Variables declared above the block within the class are valid to that inner block also.

17. Casting Incompatible types ?

Can be done either implicitly and explicitly.

ie. int b = (int) c; where c is float.
There are two types of castings related to classes :
1) unicast and
2) multicast.

18. What does String define ?

String is an array of characters, but in java it defines an object.
and the variable of type string can be assigned to another variable of type String.

19. How do you define break and Label ?

We can declare as break "label name" and the label is declared as "label name" : { ….. };
The break statement can be declared anywhere in the program ie either inside the label or outside the label.

20. Define this , finalize, and final( for variables, methods, classes ) ?

this is used inside any method to refer to the current object. and is mostly avoided.
finalize method is used to perform the actions specified in this method just before an object is destroyed. ie just before garbage collector process.
final with variables is we cant change the literals of the variables ie nothing but const.
final with method means we cant override that method.
final with class means we cannot have derived classes of that particular class.



إرسال تعليق