day 9-exception handling

day 9-exception handling

Professional Development

5 Qs

quiz-placeholder

Similar activities

Java_3

Java_3

Professional Development

5 Qs

Quiz for Module2

Quiz for Module2

Professional Development

10 Qs

Talent Next Quiz-5

Talent Next Quiz-5

Professional Development

10 Qs

PreTrainingExceptions

PreTrainingExceptions

Professional Development

10 Qs

Java_4

Java_4

Professional Development

6 Qs

C Structures

C Structures

Professional Development

10 Qs

Scala Beginner

Scala Beginner

Professional Development

10 Qs

Java_Exception

Java_Exception

Professional Development

10 Qs

day 9-exception handling

day 9-exception handling

Assessment

Quiz

Professional Development

Professional Development

Medium

Created by

Nirmala Sherine

Used 2+ times

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is wrong in the following program?

class Test {
   public static void main (String[] args) {
     try {
       System.out.println("Welcome to Java");
      }
   }
}

You cannot have a try block without a catch block.

You cannot have a try block without a catch block or a finally block.

A method call that does not declare exceptions cannot be placed inside a try block.

Nothing is wrong.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is displayed on the console when running the following program?

class Test {
   public static void main (String[] args) {
     try {
       System.out.println("Welcome to Java");
     }
     finally {
       System.out.println("The finally clause is executed");
     }
   }
}

Welcome to Java

Welcome to Java followed by The finally clause is executed in the next line

The finally clause is executed

None of the above

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of executing the following code, using the parameters 4 and 0:

 

public void divide(int a, int b) {

try {

int c = a / b;

} catch (Exception e) {

System.out.print("Exception ");

} finally {

System.out.println("Finally");

}

Prints out: Exception Finally

Prints out: Finally

Prints out: Exception

No output

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The class java.lang.Exception

is public

implements Throwable

extends Throwable

is serializable

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these is a legal definition of a method named m assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer.

void m() throws IOException{}

void m() throw IOException{}

void m(void) throws IOException{}

m() throws IOException{}

void m() {} throws IOException