10:28 pm - Monday March 27, 2017

Basic Interview Question6

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

59.  Is main a keyword in Java?
No, main is not a keyword in Java.
60.          Is next a keyword in Java?
No, next is not a keyword.

61.          Is delete a keyword in Java?
No, delete is not a keyword in Java. Java does not make use of explicit destructors the way C++ does.

62.          Is exit a keyword in Java?
No. To exit a program explicitly you use exit method in System object.

63.          What happens if you dont initialize an instance variable of any of the primitive types in Java?
Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0, a boolean will be initialized to false.

64.          What will be the initial value of an object reference which is defined as an instance variable?
The object references are all initialized to null in Java. However in order to do anything useful with these references, you must set them to a valid object, else you will get NullPointerExceptions everywhere you try to use such default initialized references.

65.          What are the different scopes for Java variables?
The scope of a Java variable is determined by the context in which the variable is declared. Thus a java variable can have one of the three scopes at any given point in time.
Instance : –
These are typical object level variables, they are initialized to default values at the time of creation of object, and remain accessible as long as the object accessible.
Local : –
These are the variables that are defined within a method. They remain accessbile only during the course of method excecution. When the method finishes execution, these variables fall out of scope.
Static: –
These are the class level variables. They are initialized when the class is loaded in JVM for the first time and remain there as long as the class remains loaded. They are not tied to any particular object instance.

66.          What is the default value of the local variables?
The local variables are not initialized to any default value, neither primitives nor object references. If you try to use these variables without initializing them explicitly, the java compiler will not compile the code. It will complain abt the local varaible not being initilized..

67.          Can main method be declared final?
Yes, the main method can be declared final, in addition to being public static.

68.          What will be the output of the following statement?
System.out.println (“1″ + 3);
It will print 13.

 

Filed in: Z-A Interview Questions

No comments yet.

Leave a Reply