Question
Java Programming
Q4 a. List five common examples of exceptions b. What is resource leak c. What happens if several catch blocks match the ty
0 0
Add a comment Improve this question Transcribed image text
Answer #1

sol:

a) 1. ArithmeticException:

           when error occurred in arithmetic operations this exception occurs

    2. ArrayIndexOutOfBoundsException

            when array accessed with illegal index (that is index is greater or equal to size of array ) this exception

           occurs

3. IOException

        if input output operation failed, this exception occurs

    4. NoSuchFieldException

       if the field doesn't exist in class this exception occurs

    5. FileNotFoundException

           if the file is not accessiable this exception occurs

b) Resource leak:

Leak occurs when you are not close a reader, scanner, buffer, or another process that uses resources and      

     needs to clean them up out of memory. Then call scanner. close(), after we can use the Scanner for whatever

   we want to do with scanner. This leak is called resource leak.

c) First matching catch block executed, after the try block is executed.

d) Finally block is used to execute important code such as closing connection, stream etc. It always executed

     whether exception is handled or not.

      

              

Add a comment
Know the answer?
Add Answer to:
Java Programming Q4 a. List five common examples of exceptions b. What is "resource leak" c....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a) List common examples of exceptions and explain how exceptions are handles in c++. (try, catch,...

    a) List common examples of exceptions and explain how exceptions are handles in c++. (try, catch, throw) b) Declare an abstract class Fraction that can be used for arithmetic of the * operator.

  • Exception handling All Exceptions that can be thrown must descend from this Java class: The getMessage(...

    Exception handling All Exceptions that can be thrown must descend from this Java class: The getMessage( ) method is inherited from this class? What are the two broad catagories of Exceptions in Java? If an Exception is not a checked exception it must extend what class? What is the difference between a checked Exception and an unchecked Exception? What are the two options a programmer has when writing code that may cause a checked Exception to be thrown? Can a...

  • 1) In Java, a library of classes is called a) an application b) a folder c)...

    1) In Java, a library of classes is called a) an application b) a folder c) a directory d) a package 2) In the technique of Top-Down design, the problem of designing a method is divided into subproblems, which are then solved using the same technique. a) true b) false 3) It is possible to have two methods in the same class that have the same name, the same number and types of arguments, but different return types. a) true...

  • Part 2: Programming with Exceptions In this part of the lab , you will write a...

    Part 2: Programming with Exceptions In this part of the lab , you will write a program that fetches the information stored at a give URL on the web and saves that data to a file. This will also include networking and file operations and partly an exercise in using exceptions. For doing I/O, Java has a pair of nice abstractions: InputStream and OutputStream. These are abstract classes in the package java.io. An InputStream is a place from which you...

  • Advanced Object-Oriented Programming using Java Assignment 4: Exception Handling and Testing in Java Introduction -  This assignment...

    Advanced Object-Oriented Programming using Java Assignment 4: Exception Handling and Testing in Java Introduction -  This assignment is meant to introduce you to design and implementation of exceptions in an object-oriented language. It will also give you experience in testing an object-oriented support class. You will be designing and implementing a version of the game Nim. Specifically, you will design and implement a NimGame support class that stores all actual information about the state of the game, and detects and throws...

  • 3. (a) Outline any four features of Object-Oriented Programming OOP, giving examples in each case. [16...

    3. (a) Outline any four features of Object-Oriented Programming OOP, giving examples in each case. [16 marks]      (b) Consider the following code fragments: If   a = 10; Evaluate the new value of “b” in the following:                (i)   b =   ++ a;               (ii) b = a ++;             What value would a and b store in (i) and (ii) after program execution?                                                                                                            [4 marks] 4. Create a C++ program that makes use of three arrays; name, mark, grade. The program should accept...

  • Programming Assignment 9 The purpose of this programming project is to demonstrate a significant culmination of...

    Programming Assignment 9 The purpose of this programming project is to demonstrate a significant culmination of most constructs learned thus far in the course. This includes Lists, Classes, accessors, mutators, constructors, implementation of Comparable, Comparator, use of Collections sort, iterators, properly accessing fields of complex objects, and fundamental File I/O. BACKGROUND Look over Programming Project #4 at the end of the Searching & Sorting Chapter (13), page 869. Programming Assignment 9 is similar with some added features as described below....

  • In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list...

    In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...

  • Please use Java only. Write a class, ZeroException, which is an Exception, and is used to signal...

    Please use Java only. Write a class, ZeroException, which is an Exception, and is used to signal that something is zero when it shouldn't be. -- Not needed Write the class ArrayManipulator which creates an array and provides several methods to manipulate values taken from an array. --needed ZeroException Task: -- Not needed Exceptions are used to signal many types of problems in a program. We can write our own as well to describe specific exceptional conditions which may arise....

  • Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What...

    Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort    Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT