Saturday, August 21, 2010

java interview questions 7

Java Interview Questions



Question: Is Empty .java file a valid source file?
Question: Can a .java file contain more than one java classes?
Question: Is String a primitive data type in Java?
Question: Is main a keyword in Java?
Question: Is next a keyword in Java?
Question: Is delete a keyword in Java?
Question: Is exit a keyword in Java?
Question: What happens if you dont initialize an instance variable of any of the primitive types in Java?
Question: What will be the initial value of an object reference which is defined as an instance variable?
Question: What are the different scopes for Java variables?
Question: What is the default value of the local variables?
Question: How many objects are created in the following piece of code?
MyClass c1, c2, c3;
c1 = new MyClass ();
c3 = new MyClass ();
Question: Can a public class MyClass be defined in a source file named YourClass.java?
Question: Can main method be declared final?
Question: What will be the output of the following statement?
System.out.println ("1" + 3);
Question: What will be the default values of all the elements of an array defined as an instance variable?



Q:
Is Empty .java file a valid source file?

A: Yes, an empty .java file is a perfectly valid source file.

[Received from Sandesh Sadhale]
TOP

Q:
Can a .java file contain more than one java classes?

A: Yes, a .java file contain more than one java classes, provided at the most one of them is a public class.

[ Received from Sandesh Sadhale]
TOP

Q:
Is String a primitive data type in Java?

A: No String is not a primitive data type in Java, even though it is one of the most extensively used object. Strings in Java are instances of String class defined in java.lang package.

[ Received from Sandesh Sadhale]
TOP

Q:
Is main a keyword in Java?

A: No, main is not a keyword in Java.

[ Received from Sandesh Sadhale]
TOP

Q:
Is next a keyword in Java?

A: No, next is not a keyword.

[ Received from Sandesh Sadhale]
TOP

Q:
Is delete a keyword in Java?

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

[ Received from Sandesh Sadhale]
TOP

Q:
Is exit a keyword in Java?

A: No. To exit a program explicitly you use exit method in System object.

No comments:

Post a Comment