Java Basics - Interview Questions and Answers
What is the catch or declare rule for method declarations?
If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.
Is Empty .java file a valid source file?
Yes. An empty .java file is a perfectly valid source file.
Can a .java file contain more than one java classes?
Yes. A .java file contain more than one java classes, provided at the most one of them is a public class.
Is String a primitive data type in Java?
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.
Is main a keyword in Java?
No. main is not a keyword in Java.
Is next a keyword in Java?
No. next is not a keyword.