Question 1 of 25
Hints left: 3
Q1
Which of these methods is used to print stack trace?
Q2
Which of these keywords is used to generate an exception explicitly?
Q3
Which interface is used to create a thread in Java?
Q4
What is the result of calling the run() method directly instead of start() in Java threads?
Q5
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"); } } }
Q6
What is the main advantage of using multithreading in Java programs?
Q7
How can you achieve synchronization between threads in Java?
Q8
In Java, can a thread be restarted after it has completed execution?
Q9
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"); } } }
Q10
Which of the following handles the exception when a catch is not used?
Q11
Which of these clause will be executed even if no exceptions are found?
Q12
What is the purpose of the start() method in Java threads?
Q13
Which of these keywords is not a part of exception handling?
Q14
Which of these handles the exception when no catch is used?
Q15
What is a thread in Java?
Q16
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 "); } } }
Q17
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); } }
Q18
What exception thrown by parseInt() method?
Q19
What is a race condition in multithreaded Java programs?
Q20
A single try block must be followed by which of these?
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 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"); } } }
Q23
How can you create a new thread in Java by implementing the Runnable interface?
Q24
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"); } } }
Q25
Which of these methods return description of an exception?