Java Online Quiz
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.
Answer : A
Explaination
The byte data type is represented by an 8-bit signed two's complement integer.
Minimum value: -128
Maximum value: 127
Answer : A
Explaination
True, a java file can contain one public class and many other non-public classes.
Answer : A
Explaination
char variable has default value of '\u0000' if defined as an instance/static variable.
Q 4 - Which of the following is false about String?
B - String can be created using new operator.
Answer : C
Explaination
String is a object.
Q 5 - What is Encapsulation?
A - Encapsulation is a technique to define different methods of same type.
B - Encapsulation is the ability of an object to take on many forms.
Answer : C
Explaination
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.
Q 6 - What is static block?
Answer : C
Explaination
static block is used to initialize the static data member.It is executed before main method at the time of loading of a class.
Q 7 - Static binding uses which information for binding?
Answer : A
Explaination
Static binding uses type information for binding.
Q 8 - What is a transient variable?
A - A transient variable is a variable which is serialized during Serialization.
B - A transient variable is a variable that may not be serialized during Serialization.
C - A transient variable is a variable which is to be marked as serializable.
Answer : B
Explaination
A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization.
Answer : A
Explaination
Yes, try statements be nested.
Q 10 - In which case, a program is expected to recover?
Answer : B
Explaination
A program is expected to recover if an exception occurs.