Select chapter



basics (7.papers)
constructors (1.papers)
packages (1.papers)
inheritance (7.papers)
misc (3.papers)
exceptions (5.papers)
threads (4.papers)
overloading (1.papers)
jsp (3.papers)
servlets (9.papers)
jdbc (2.papers)
util (1.papers)
xml (2.papers)
IO stream (3.papers)
Hide

Sponsored Links


  

java interview questions and answers

1
The finally block will be definitely get executed even if there is no exception.
  1. Yes
  2. No
  3. Depends on the placement of return statement
  4. Depends on the return type
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
Which of the following is true about printStackTrace()
  1. The printStackTrace() is used to print the output
  2. The printStackTrace() prints the trace of this exception propagation. 
  3. The printStackTrace() are used to print compilation errors
Show Answer
Share Facebook gmail Twitter
7
In which class printStackTrace() method is declared?
  1. Throwable class.
  2. Exception class.
  3. RunTimeException class.
  4. Error
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
9
Which of the following is true about exception ?
  1. Errors that occurs at compile time are called exceptions
  2. Errors that occurs at run time are called exceptions.
  3. Some compile time errors are also called as exceptions
  4.  Some run time errors are called exceptions
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
16
Which of the following options are valid when compile and run the code : 

public class MyClass {
public static void main(String[] args) {
  Error e = null;
  throw e;
}
}
  1. Throws java.lang.NullPointerException
  2. java.lang.Error
  3. The program compiles and does not throw any Exception
  4. Compile time error
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
19
Which of the options is valid when compile and run the given code:

public class MyClass { 
 public static void main(String[] args) throws A { 
  try { 
   m1(); 
  } finally { 
   System.out.println("Done."); 
  } catch (A e) { 
   throw e; 
  }
 }
 public static void m1() throws B { 
  throw new B(); 
 } 
} 
class A extends Throwable {} 
class B extends A {}
  1. Compile time Error as the main() method must throw B instead of A.
  2. Compile time Error as the finally block must follow the catch block in the main() method.
  3. Compile time Error as the catch block in the main() method must catch B rather than A.
  4. Compiles successfully and prints Done
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :