AmbitionBox

Discover Best Places to work in India

Java Programming

Java Programming Questions and Answers

Showing 71 - 80 of 150 questions

71

In case of multiple catch blocks,______

a

The superclass exception must be caught first

b

The superclass exception can't be caught first

c

Either super or subclass can be caught first

d

None of these

correct answer b
72

Which method is used to print the description of the exception?

a

printStackTrace()

b

printExceptionMessage()

c

printStackMessage()

d

printExceptionTrace()

correct answer a
73

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”);
}
a

Hello India

b

Hello India Hello Morbi

c

Hello Morbi

d

the program will return without printing anything

correct answer c
74

What will be the output of the program? public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( "Finally" ); } } }

a

Finally

b

Compilation fails.

c

The code runs with no output.

d

An exception is thrown at runtime.

correct answer a
75

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 */ } }

a

Finally

b

Compilation fails.

c

exception finished

d

finally exception finished

correct answer d
76

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 */ } }

a

ABCD

b

Compilation fails.

c

C is printed before exiting with an error message

d

BC is printed before exiting with an error message

correct answer c
77

Which of these class is used to make a thread?

a

String

b

System

c

Thread

d

Runnable

correct answer c
78

Which of these interface is implemented by Thread class?

a

Runnable

b

Set

c

Connections

d

Mapconnections

correct answer a
79

Which function of pre defined class Thread is used to check weather current thread being checked is still running?

a

isAlive()

b

Alive()

c

isRunning()

d

Join()

correct answer a
80

What is the output of this program?

classmultithreaded_programing{
        publicstaticvoidmain(String args[]){
            Thread t = Thread.currentThread();
            t.setName("New Thread");
            System.out.println(t);        
        }
    }
a

Thread[5,main]

b

Thread[New Thread,5]

c

Thread[main,5,main]

d

Thread[New Thread,5,main]

correct answer d
Select a company to compare with

vs

Similar Companies