InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of these methods return localized description of an exception?(a) getLocalizedMessage()(b) getMessage()(c) obtainLocalizedMessage()(d) printLocalizedMessage()The question was posed to me during a job interview.Query is from Creating Exceptions in section Exception Handling of Java |
|
Answer» The CORRECT ANSWER is (a) getLocalizedMessage() |
|
| 2. |
Which of these methods is used to print stack trace?(a) obtainStackTrace()(b) printStackTrace()(c) getStackTrace()(d) displayStackTrace()I got this question in exam.This interesting question is from Creating Exceptions in section Exception Handling of Java |
|
Answer» The CORRECT OPTION is (B) printStackTrace() |
|
| 3. |
Which of these methods return description of an exception?(a) getException()(b) getMessage()(c) obtainDescription()(d) obtainException()I have been asked this question in a job interview.Asked question is from Creating Exceptions topic in portion Exception Handling of Java |
|
Answer» CORRECT answer is (B) getMessage() Easy explanation: getMessage() returns a description of the EXCEPTION. |
|
| 4. |
Which of these classes is used to define exceptions?(a) Exception(b) Throwable(c) Abstract(d) SystemThis question was addressed to me in an online interview.Question is from Creating Exceptions in portion Exception Handling of Java |
|
Answer» RIGHT CHOICE is (a) Exception For EXPLANATION: NONE. |
|
| 5. |
Which of these keywords are used for generating an exception manually?(a) try(b) catch(c) throw(d) checkI had been asked this question by my college professor while I was bunking the class.The above asked question is from Try & Catch in division Exception Handling of Java |
|
Answer» RIGHT CHOICE is (C) throw The EXPLANATION: NONE. |
|
| 6. |
Which of these keywords are used for the block to handle the exceptions generated by try block?(a) try(b) catch(c) throw(d) checkThe question was posed to me during an internship interview.My question comes from Try & Catch topic in division Exception Handling of Java |
|
Answer» RIGHT ANSWER is (B) catch Easiest EXPLANATION: NONE. |
|
| 7. |
Which of these keywords are used for the block to be examined for exceptions?(a) try(b) catch(c) throw(d) checkI got this question by my college director while I was bunking the class.This key question is from Try & Catch in division Exception Handling of Java |
|
Answer» Right CHOICE is (a) TRY |
|
| 8. |
A single try block must be followed by which of these?(a) finally(b) catch(c) finally & catch(d) none of the mentionedThis question was addressed to me by my college director while I was bunking the class.The doubt is from Finally & Built in Exceptions topic in section Exception Handling of Java |
|
Answer» The correct OPTION is (c) finally & catch |
|
| 9. |
Which of these exceptions handles the divide by zero error?(a) ArithmeticException(b) MathException(c) IllegalAccessException(d) IllegarExceptionI got this question in semester exam.The question is from Finally & Built in Exceptions in chapter Exception Handling of Java |
|
Answer» RIGHT ANSWER is (a) ArithmeticException The EXPLANATION is: NONE. |
|
| 10. |
What is the use of try & catch?(a) It allows us to manually handle the exception(b) It allows to fix errors(c) It prevents automatic terminating of the program in cases when an exception occurs(d) All of the mentionedThe question was asked in final exam.Asked question is from Try & Catch topic in section Exception Handling of Java |
|
Answer» CORRECT ANSWER is (d) All of the mentioned Best EXPLANATION: NONE. |
|
| 11. |
Which of these clause will be executed even if no exceptions are found?(a) throws(b) finally(c) throw(d) catchThe question was asked during an internship interview.Enquiry is from Finally & Built in Exceptions in division Exception Handling of Java |
|
Answer» Right choice is (b) finally |
|
| 12. |
Which of these operator is used to generate an instance of an exception than can be thrown by using throw?(a) new(b) malloc(c) alloc(d) thrownThe question was asked by my school principal while I was bunking the class.The question is from Throw, Throws & Nested Try in chapter Exception Handling of Java |
|
Answer» RIGHT choice is (a) NEW Easy explanation: new is USED to create an instance of an exception. All of java’s built in run-time exceptions have two constructors: one with no parameters and one that TAKES a STRING parameter. |
|
| 13. |
Which of these class is related to all the exceptions that can be caught by using catch?(a) Error(b) Exception(c) RuntimeExecption(d) All of the mentionedI had been asked this question in an interview.Query is from Exceptions Types in section Exception Handling of Java |
|
Answer» Right ANSWER is (b) EXCEPTION |
|
| 14. |
Which of these class is related to all the exceptions that are explicitly thrown?(a) Error(b) Exception(c) Throwable(d) ThrowI had been asked this question in final exam.This intriguing question comes from Throw, Throws & Nested Try topic in section Exception Handling of Java |
|
Answer» RIGHT OPTION is (C) Throwable To ELABORATE: NONE. |
|
| 15. |
Which of these class is related to all the exceptions that cannot be caught?(a) Error(b) Exception(c) RuntimeExecption(d) All of the mentionedI got this question in exam.This interesting question is from Exceptions Types topic in chapter Exception Handling of Java |
|
Answer» The CORRECT option is (a) Error |
|
| 16. |
Which of these keywords is used to generate an exception explicitly?(a) try(b) finally(c) throw(d) catchThis question was addressed to me during an interview for a job.Origin of the question is Throw, Throws & Nested Try topic in section Exception Handling of Java |
|
Answer» CORRECT ANSWER is (C) throw Best EXPLANATION: NONE. |
|
| 17. |
Which of these handles the exception when no catch is used?(a) Default handler(b) finally(c) throw handler(d) Java run time systemThe question was asked during an interview for a job.Query is from Exceptions Types topic in section Exception Handling of Java |
|
Answer» RIGHT CHOICE is (a) DEFAULT handler Explanation: NONE. |
|
| 18. |
Which of the following should be true of the object thrown by a thrown statement?(a) Should be assignable to String type(b) Should be assignable to Exception type(c) Should be assignable to Throwable type(d) Should be assignable to Error typeThis question was posed to me by my school teacher while I was bunking the class.This key question is from Exception Handling in portion Exception Handling of Java |
|
Answer» The CORRECT choice is (c) Should be ASSIGNABLE to THROWABLE type |
|
| 19. |
Which of these is a super class of all exceptional type classes?(a) String(b) RuntimeExceptions(c) Throwable(d) CacheableI have been asked this question in an internship interview.Query is from Exceptions Types topic in section Exception Handling of Java |
|
Answer» The CORRECT choice is (C) Throwable |
|
| 20. |
At runtime, error is recoverable.(a) True(b) FalseI have been asked this question by my college professor while I was bunking the class.I'd like to ask this question from Exception Handling topic in chapter Exception Handling of Java |
|
Answer» Correct option is (b) False |
|
| 21. |
Which part of code gets executed whether exception is caught or not?(a) finally(b) try(c) catch(d) throwThis question was addressed to me in a national level competition.I want to ask this question from Exception Handling topic in chapter Exception Handling of Java |
|
Answer» The correct option is (a) FINALLY |
|
| 22. |
Which of the following handles the exception when a catch is not used?(a) finally(b) throw handler(c) default handler(d) java run time systemI got this question by my school principal while I was bunking the class.Question is taken from Exception Handling in portion Exception Handling of Java |
|
Answer» Right option is (C) default handler |
|
| 23. |
Which of the following operators is used to generate instance of an exception which can be thrown using throw?(a) thrown(b) alloc(c) malloc(d) newThe question was asked during an online interview.This intriguing question originated from Exception Handling in section Exception Handling of Java |
|
Answer» RIGHT CHOICE is (d) new For explanation I would say: new OPERATOR is used to CREATE instance of an exception. Exceptions may have parameter as a String or have no parameter. |
|
| 24. |
Which of the following keyword is used by calling function to handle exception thrown by called function?(a) throws(b) throw(c) try(d) catchThis question was posed to me during an interview for a job.Question is from Exception Handling in section Exception Handling of Java |
|
Answer» CORRECT answer is (a) throws To explain I would say: A method specifies behaviour of being capable of causing exception. Throws clause in the method DECLARATION GUARDS caller of the method from exception. |
|
| 25. |
Which of the following is a super class of all exception type classes?(a) Catchable(b) RuntimeExceptions(c) String(d) ThrowableThe question was asked in class test.I want to ask this question from Exception Handling topic in section Exception Handling of Java |
|
Answer» Correct ANSWER is (d) THROWABLE |
|
| 26. |
Which of the following classes can catch all exceptions which cannot be caught?(a) RuntimeException(b) Error(c) Exception(d) ParentExceptionI got this question in a national level competition.My question is from Exception Handling in portion Exception Handling of Java |
|
Answer» Correct CHOICE is (b) Error |
|
| 27. |
Which of the following keywords is used for throwing exception manually?(a) finally(b) try(c) throw(d) catchI had been asked this question by my school principal while I was bunking the class.I'd like to ask this question from Exception Handling topic in chapter Exception Handling of Java |
|
Answer» RIGHT choice is (c) throw Easy explanation: “throw’ KEYWORD is used for throwing exception manually in JAVA PROGRAM. User defined exceptions can be thrown too. |
|
| 28. |
Which of these keywords must be used to monitor for exceptions?(a) try(b) finally(c) throw(d) catchI have been asked this question by my school teacher while I was bunking the class.My query is from Exceptional Handling Basics in section Exception Handling of Java |
|
Answer» The CORRECT OPTION is (a) try |
|
| 29. |
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?(a) try(b) finally(c) throw(d) catchThis question was posed to me by my school teacher while I was bunking the class.Enquiry is from Exceptional Handling Basics topic in section Exception Handling of Java |
|
Answer» RIGHT answer is (d) catch Explanation: If an exception OCCURS within the try BLOCK, it is thrown and CACHED by catch block for processing. |
|
| 30. |
Which of these keywords is not a part of exception handling?(a) try(b) finally(c) thrown(d) catchI got this question in an interview for internship.Enquiry is from Exceptional Handling Basics topic in division Exception Handling of Java |
|
Answer» Correct answer is (c) thrown |
|
| 31. |
When does Exceptions in Java arises in code sequence?(a) Run Time(b) Compilation Time(c) Can Occur Any Time(d) None of the mentionedThis question was posed to me during an interview for a job.This interesting question is from Exceptional Handling Basics in chapter Exception Handling of Java |
|
Answer» The correct choice is (a) Run Time |
|