Java Programming Questions and Answers
In case of multiple catch blocks,______
Which method is used to print the description of the exception?
What is the output of following try catch block try
{ int i; return; } catch(Exception e) { System.out.println('Hello Indiaâ€); } finally { System.out.println('Hello Morbiâ€); }
What will be the output of the program? public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }
What will be the output of the program? public class Test { public static void aMethod() throws Exception { try /* Line 5 */ { throw new Exception(); /* Line 7 */ } finally /* Line 9 */ { System.out.print("finally "); /* Line 11 */ } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) /* Line 20 */ { System.out.print("exception "); } System.out.print("finished"); /* Line 24 */ } }
What will be the output of the program? public class X { public static void main(String [] args) { try { badMethod(); System.out.print("A"); } catch (Exception ex) { System.out.print("B"); } finally { System.out.print("C"); } System.out.print("D"); } public static void badMethod() { throw new Error(); /* Line 22 */ } }
Which of these class is used to make a thread?
Which of these interface is implemented by Thread class?
Which function of pre defined class Thread is used to check weather current thread being checked is still running?
What is the output of this program?
classmultithreaded_programing{
publicstaticvoidmain(String args[]){
Thread t = Thread.currentThread();
t.setName("New Thread");
System.out.println(t);
}
}