Skip to content

CSE2137 - Object Oriented Programming

Exception Handling

Term 151

  • Q4(a) [4]: Explain exception handling in Java. Write a program that generated custom exception if any integer value given from its command line arguments is negative.
  • Q4(b) [6]: Explain the importance of exception handling in Java? Which keywords are used to handle exceptions? Write a program to explain the use of these keywords.

Term 161

  • Q3(a) [4]: Explain exception handling in JAVA. Write a program that generates custom exception if any integer value given from its command line arguments is negative.
  • Q3(b) [3]: Write a Java program to check the divide-by-zero error of the modulo of two integers using exception handling mechanism.
  • Q3(d) [4]: Which key words are used to handle exceptions? Write a program to explain the use of these keywords.
  • Q7(d) [4]: What is error? Explain any three types of errors. How can we handle run time errors in java?

Term 171

  • Q4(c) [4]: Exceptions are problems that may happen in a code. In java, exceptions are categorized as Runtime Exceptions and Checked Exceptions. Explain these two types.
  • Q5(a) [2+3]: What are differences between Exception and Error in Java? Describe the purpose of the following exception handling keywords: throw, throws, try-catch and finally.

Term 181

  • Q4(a) [4]: When you write programs in java, you must be concerned about exceptions. What are exceptions? When answering this question, mention some scenarios where exceptions may happen.
  • Q4(c) [6]: In your java code, you have the following line to open a file to read the content: BufferedReader reader = new BufferedReader(new FileReader(filename)); You know very well that exceptions may be thrown here. Mention reasons you think exceptions may be thrown when trying to read a file. Show in code how you would handle the exception/s in this case.

Term 201

  • Q4(c) [1+5]: What does exception mean in Java? Write a java program to enter two numbers and calculate the quotient. Use exception handling mechanism to take care of the divide by zero situation.
  • Q5(d) [2]: What will be the Output of the below code?

public class A {
    public static void main(String[] args) {
        if (true)
            break;
    }
}

- Q6(a) [2]: What is the difference between Exception and Error in Java?
- Q6(d) [4]: What is the difference between checked and unchecked exceptions in Java? Give ONE (1) example of each of these types of exceptions.

Term 211

  • Q3(b) [2+1+3]: Differentiate between Exception and Error in Java. Write a Java Program to check the divide-by-zero error of the modulo of two integers using exception handling mechanism.
  • Q3(c) [2+3]: Which keywords are used to handle exceptions? Write a program to explain the use of these keywords.
  • Q5(d) [5]: How many types of Exceptions can occur in a Java program? Describe with examples.