Question 1 of 25
Hints left: 3
Q1
Which of these keywords is used to generate an exception explicitly?
Q2
A single try block must be followed by which of these?
Q3
What is the result of calling the run() method directly instead of start() in Java threads?
Q4
What is a thread in Java?
Q5
In Java, can a thread be restarted after it has completed execution?
Q6
How can you create a new thread in Java by implementing the Runnable interface?
Q7
Which of these handles the exception when no catch is used?
Q8
What will be the output of the following Java code? class Myexception extends Exception { int detail; Myexception(int a) { detail = a; } public String toString() { return "detail"; } } class Output { static void compute (int a) throws Myexception { throw new Myexception(a); } public static void main(String args[]) { try { compute(3); } catch(DevideByZeroException e) { System.out.print("Exception"); } } }
Q9
Which of these methods return description of an exception?
Q10
What is a race condition in multithreaded Java programs?
Q11
Which of these clause will be executed even if no exceptions are found?
Q12
What is the main advantage of using multithreading in Java programs?
Q13
What will be the output of the following Java program? class exception_handling { public static void main(String args[]) { try { int i, sum; sum = 10; for (i = -1; i < 3 ;++i) sum = (sum / i); } catch(ArithmeticException e) { System.out.print("0"); } System.out.print(sum); } }
Q14
What will be the output of the following Java program? class exception_handling { public static void main(String args[]) { try { System.out.print("Hello" + " " + 1 / 0); } catch(ArithmeticException e) { System.out.print("World"); } } }
Q15
Which interface is used to create a thread in Java?
Q16
What exception thrown by parseInt() method?
Q17
What will be the output of the following Java program? class exception_handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } finally { System.out.print("C"); } } }
Q18
Which of these keywords is not a part of exception handling?
Q19
Which of the following handles the exception when a catch is not used?
Q20
What will be the output of the following Java code? class Output { public static void main(String args[]) { try { int a = 0; int b = 5; int c = b / a; System.out.print("Hello"); } catch(Exception e) { System.out.print("World"); } } }
Q21
Which of these class is related to all the exceptions that are explicitly thrown?
Q22
What will be the output of the following Java code? public class A { public static void main(String args[]) { try { System.out.print("Hello world "); } finally { System.out.println("Finally executing "); } } }
Q23
How can you achieve synchronization between threads in Java?
Q24
Which of these methods is used to print stack trace?
Q25
What is the purpose of the start() method in Java threads?