Java - Online Test - Exception - javasearch.buggybread.com


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'Exception' - 13 questions found


Which of the following exception is thrown when we try to access element which is beyond the size ?Core Java
NullPointerException
ArrayIndexOutOfBoundException
ArithmeticException
ParseException

  java  exceptions  error handling

Checked exception needs to be ... Core Java
Caught
Method needs to declare that it throws these exception
Either A or B
Both A and B

  java  exceptions  checked exceptions

Which of the following is not possible ?Core Java
try block followed by catch
try block followed by finally
try block followed by catch block and then finally
try block without catch or finally block

  exceptions  java  try-catch  finally

Invoking start twice on same thread leads to ..Core Java
ClassCastException
NullPointerException
InterruptedException
IllegalStateException

  java  exception  threads

In Case a method is declared to throw an exception , We can only use a call to that method if ...Core Java
We use the call within try block and catch the exception
We declare that the method is expected to throw the exception using throws
Both 1 and 2
Either 1 or 2

  exception handling  throws

Which of the following is true ?Core Java
throw and throws are used to throw an exception
throw is used to throw an exception whereas throws is a declaration that the method can throw the exception
throws is used to throw an exception whereas throw is a declaration that the method can throw the exception
throw and throws are used to declare that an exception can be thrown by the method

  throw  throws  exception handling

throws is a declaration that the ..... is expected to throw an exception ?Core Java
Variable
Method
Class
Interface

  throws  exception handling

Which of following is not the resolution for preventing LazyInitializationException?Hibernate
Set fetch=FetchType.EAGER for Dependent entity mapping
Make sure that we are accessing the dependent objects before closing the session
Make sure that we are accessing the dependent objects after closing the session
Wrap the complete access within Transaction

  Hibernate  LazyInitializationException

Which of the following is a valid way to avoid NullPointerException ?Core Java
Avoid assigning null to the reference
Null Checks before accessing elements of an object
Both of the above
None of the above

  NullPointerException  null

Which of the following can throw ClassCastException ?Core Java
UpCasting
DownCasting
Casting to incompatible data type
Casting to Strings

  casting

x instanceOf y returns false ..Core Java
if x is an instance of y class
if x is an instance of class implementing y interface
if x is an instance of class extending y class
if x is an instance of Class which is a parent of Y class

  instaceOf

Which of the following is not an advantage of JSON over XML ?JSON
Lighter and Faster
Object Representation
Supports multiple data types
Backward compatible with all XML applications

  JSON  XML

In which case finally won't get executed ?Core Java
in case of exception
in case of normal execution
in case of return statement before end of try block
in case of force program termination

  finally







comments powered by Disqus