Java: An Introduction to Problem Solving and Programming (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 9.3, Problem 32STQ
Program Plan Intro

Try and catch block:

Java virtual machine (JVM) searches to handle the error in “catch” clause at that time of exception in the program. So “try-catch” statements are used in order to handle those exceptions. The following are the main keywords used in exception handling.

  • • “try” block: Try block contains the block of statements to monitor the exception and it thrown the exception. It is possible to have a “try” block inside another large “try” block and “catch” block.
  • • “catch” block: Catch block catch exception thrown by the try block to handle it.

Syntax:

// class definition

class class_name

{

    // Try block

    try

    {

        // Try block statement

    }

  // Catch block

    catch(Excep1 exObj)

    {

        // Catch block statement

    }

}

Blurred answer
Students have asked these similar questions
Is it possible to include a try block and its associated catch blocks inside a larger catch block?
Is there a limit to how many parameters a catch block may have?
Can a try block and its related catch blocks be contained within a larger catch block?

Chapter 9 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education