Java MCQ – Home
Java Basic MCQ
➤ Java Hello World MCQ
➤ Find Java Keywords
➤ Java Identifier Quiz
➤ Java Data Types Quiz
➤ If-Else MCQ in Java-1
➤ If-Else MCQ in Java-2
Object class MCQ
➤ Object Class Quiz
➤ equals() Method Quiz
➤ Hashcode Value Quiz
➤ toString() Method Quiz
➤ Clone() Method Quiz
Multithreading MCQ
➤ Define a Thread-1
➤ Define a Thread-2
➤ Get/set ThreadName
➤ Thread State MCQ
➤ Thread Priority MCQ
➤ Yield(), join() & sleep()
➤ Synchronization MCQ
➤ Interthread Comms
➤ Deadlock, Daemon
Exception Handling
➤ Exception Handling-1
➤ Exception Handling-2
➤ Exception Handling-3
➤ Java try-catch MCQ-1
➤ Java try-catch MCQ-2
➤ Java try-catch MCQ-3
➤ Nested try-catch MCQ
➤ throw Keyword MCQ
➤ finally Block MCQ-1
➤ finally Block MCQ-2
➤ throws Keyword MCQ
Generics MCQ
➤ Java Generics Quiz-1
➤ Java Generics Quiz-2
➤ Java Generics Quiz-3
Collection Framework
➤ Collections Quiz-1
➤ Collections Quiz-2
➤ ArrayList MCQ-1
➤ ArrayList MCQ-2
➤ LinkedList MCQ
➤ Vector Stack MCQ
➤ Java Cursors MCQ
➤ Java TreeSet MCQ
➤ TreeSet & Comparator
Q1) Which class acts as the root for all Java exception Hierarchy?
a) Exception class
b) Throwable class
c) Error class
d) None of these
View Answer
Answer:- b) Throwable classQ2) Which option is true?
a) Throwable is an interface.
b) Throwable is an abstract class.
c) Throwable is a class.
d) Throwable is an Enum.
View Answer
Answer:- c) Throwable is a class.Q3) Throwable class contains how many child classes?
a) 2
b) 0
c) 1
d) 3
View Answer
Answer:- a) 2Throwable class contains 2 child classes:- Exception and Error.
Q4) We get checked exceptions at (Or, checked exception raises at)?
a) Compile time
b) Runtime
c) Both (a) and (b)
d) None of these
View Answer
Answer:- b) RuntimeWhether it is a checked exception or unchecked exception, all exceptions are raised at runtime only.
Q5) Which exception will raise in the below statement?
System.out.println(9/0);
a) NumberFormatException
b) RuntimeException
c) ArithmeticException
d) None of these
View Answer
Answer:- c) ArithmeticExceptionjava.lang.ArithmeticException: / by zero
Q6) Which exception will raise in the below statement?
int n1 = Integer.parseInt("ten");
a) NumberFormatException
b) NullPointerException
c) ArithmeticException
d) None of these
View Answer
Answer:- a) NumberFormatExceptionjava.lang.NumberFormatException: For input string: “ten”
Q7) Which exception will raise in the below statement?
String s = null;
System.out.println(s.length());
a) NumberFormatException
b) NullPointerException
c) ArithmeticException
d) None of these
View Answer
Answer:- b) NullPointerExceptionjava.lang.NullPointerException: Cannot invoke “String.length()” because “s” is null.
Q8) RuntimeException class is a subclass of?
a) Error
b) Exception
c) ArithmeticException
d) None of these
View Answer
Answer:- b) ExceptionQ9) Which keyword is not used in exception handling?
a) throw
b) throws
c) thrown
d) All of these
View Answer
Answer:- c) thrownJava doesn’t contain the “thrown” keyword.
Q10) How many keywords are given to work with exceptions?
a) 5
b) 4
c) 3
d) 9
View Answer
Answer:- a) 5In Java 5 keywords are given specially to work with exception. They are:- try, catch, finally, throw and throws.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!