Following quiz provides Multiple Choice Questions (MCQs) related to Core Java. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What is correct syntax for main method of a java class?
Correct syntax is public static void main(String args).
No, a java file can contain only one public class.
String variable has default value of null if defined as an instance/static variable.
Q 4 - Which of the following stands true about default modifier of class members?
By default, variables, methods and constructors can be accessed by any class lying in the same package.
Q 5 - What is Encapsulation?
It is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. Therefore encapsulation is also referred to as data hiding.
Yes, class with private constructor can not instantiated using new keyword.
Q 7 - What is function overloading?
If a class has multiple functions by same name but different parameters, it is known as Method Overloading.
Q 8 - What is a transient variable?
A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization.
Q 9 - Under what conditions is an object's finalize() method invoked by the garbage collector?
The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.
Q 10 - What is a marker interface?
Marker interface is an interface with no method.