UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What happens if an exception occurs in catch block?

Asked by Last Modified  

14 Answers

Learn Java

Follow 0
Answer

Please enter your answer

That error message will get printed.
Comments

Tutor

Exception will be thrown in try block, It will be catches by subsequent catch blocks.Suppose the exception occur in catch block ,then you need to write a separate try catch block in order to catch it. For ex: try { int a=15/0; }catch(ArithmeticException e) ...
read more
Exception will be thrown in try block, It will be catches by subsequent catch blocks.Suppose the exception occur in catch block ,then you need to write a separate try catch block in order to catch it. For ex: try { int a=15/0; }catch(ArithmeticException e) { System.out.println("ArithmeticException occurred"); int b=20/0; } Output is :- ArithmeticException occurred Exception in thread "main" java.lang.ArithmeticException: / by zero at com.ipaccess.nos.usersettings.alarm.filter.TestProgram.main(Test.java:18) but if you write statement "int b=20/0" inside try catch block ,then program will catch it and print the required message. try { int a=15/0; }catch(ArithmeticException e) { System.out.println("Arithmetic Exception1 occurred"); try { int b=20/0; }catch(ArithmeticException e1) { System.out.println("Arithmetic Exception2 occurred"); } } Output is: Arithmetic Exception occurred1 ArithmeticException occurred2 After that It will stop the execution read less
Comments

Tutor

Exception will be thrown in try block, it will be caught by subsequent catch blocks. Suppose the exception occur in catch block ,then you need to write a separate try catch block in order to catch it. For ex: try { int a=15/0; }catch(ArithmeticException e) ...
read more
Exception will be thrown in try block, it will be caught by subsequent catch blocks. Suppose the exception occur in catch block ,then you need to write a separate try catch block in order to catch it. For ex: try { int a=15/0; }catch(ArithmeticException e) { System.out.println("ArithmeticException occurred"); int b=20/0; } Output is :- ArithmeticException occurred Exception in thread "main" java.lang.ArithmeticException: / by zero at com.ipaccess.nos.usersettings.alarm.filter.TestProgram.main(Test.java:18) but if you write statement "int b=20/0" inside try catch block ,then program will catch it and print the required message. try { int a=15/0; }catch(ArithmeticException e) { System.out.println("Arithmetic Exception1 occurred"); try { int b=20/0; }catch(ArithmeticException e1) { System.out.println("Arithmetic Exception2 occurred"); } } Output is: Arithmetic Exception occurred1 ArithmeticException occurred2 After that It will stop the execution read less
Comments

Software Engineer with 15 years of Professional experience in MNCs (JP Morgan, TCS, Mastek)

The same exception semantics apply. If the exception is checked, you must either handle it inside the catch block with another try-catch or declare it using the method's throws clause. The finally block will still complete; even if a runtime exception was thrown.
Comments

Tutor

its transfered to finally to give error display
Comments

Software Development Trainer

It will be thrown and in case it's handled nowhere, it will cause unhandled exception.
Comments

10 years of Hadoop Spark Expertise

We can throw the exception from catch block to another catch block where exactly it get caught.
Comments

Trainer

If a new exception is thrown in a catch block it will propagate out of that block and the current exception is aborted (and forgotten) as the new exception takes over on it. The new exception starts unwinding up the stack just like any other exception, aborting out of the current block (the catch or...
read more
If a new exception is thrown in a catch block it will propagate out of that block and the current exception is aborted (and forgotten) as the new exception takes over on it. The new exception starts unwinding up the stack just like any other exception, aborting out of the current block (the catch or finally block) and subject to any applicable catch or finally blocks along the way. read less
Comments

IT Professional Trainer with 13 years of experience in IT industry + Academics

Exception occurs in try block. Catch block used to handle those exceptions which have been occured and thrown by try block
Comments

Java Professional with over 6 years of real time experience in web application development

It will throw an exception and will stop the execution of program and . Else put a try catch inside the catch block, or the exception will be propagated to JVM.
Comments

View 12 more Answers

Related Questions

What is reflection and what is its use in Java?
Its generally meant for redefining the definition of objected oriented features in more depth to intensify its object oriented design.
Rahul
0 0
7
Hi, I am pursuing MBA 1st Year. I want to learn Digital Marketing. Is it right for career growth, or should I choose to learn some other technologies? If yes, please give me your suggestions that help me to get a JOB in the IT Sector.
Hi Sai, To find right career path you need to try things ( Which is long way). I would suggest you to learn multiple things ( implementation is important part) and then find your intrest and dive in to...
Sai
What is use of interface in Java language?
Interface are used to code re-usability, and they are the real driver of ploymorphism in Java. Interface are also allows multiple inheritance in java.
Parminder
What are the topics covered under core Java?
The major topics are listed below: 1. Java Basics - Variables, Data types, Operators, Control Statements,Strings, Arrays and Functions. 2. Object Oriented Concepts - Classes, Objects, Constructors, Inheritance,...
Sahil
0 0
6
Why do many software engineers not like Java?
Opinions on programming languages can vary, but some software engineers may express dissatisfaction with Java for reasons such as perceived verbosity, boilerplate code, and a slower pace of language evolution...
Guruprasad
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Example of DependsOnMethod in TestNG
public class dependsonM { @Test public void login() { System.out.println("login"); } @Test (dependsOnMethods = {"login"}) public void email() { //Intentionally I am failing this testcase Assert.assertTrue(false);...
S

Sarthak C.

0 0
0

Features Of Java
There is given many features of java. They are also known as java buzzwords. The Java Features given below are simple and easy to understand. i. Simple ii. Object-Oriented iii. Portable iv. Platform...

Introduction to Course Content
Video about what we are going to learn throughout the Java Training Session .

Android : Application Launch time improvements.
For any standard android application, below 3 components play important roles to show 1st interface to user, so that he/she can interact with the app. 1. Custom Application class : Intialize the components...

Java
Java is a high level language which is far better than procedural languages like C, Fortran and Pascal. Java completely stands with the principles of OOPS (Object Oriented Programming Structure). The...
A

Abhisheak Saxena

0 0
0

Recommended Articles

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more