Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8044823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:21:03+00:00 2026-06-05T05:21:03+00:00

I want to know whether an error can be handled or not in Java

  • 0

I want to know whether an error can be handled or not in Java in the similar way to exceptions. I have seen errors that can’t be handled such as AssertionError and I’ve also tried throwing an error inside a program and tried handling using catch, It worked and also the next part of code did execute(This is contradictory to the part where the program supposed to be exited whenever an error is encountered). Is it like few errors can be handled and few others cannot be. I’m confused with this, can anyone clear this doubt of mine and state the difference between errors and exceptions?

package package1;

public class Class1 
{   
public static void main(String[] args)
{
    Class1 cl1=new Class1();
    int x=2;
    String s = null;
    //assert(x<0):"x is not less than zero";
    try
    {
        cl1.workonExceptions();
    }
    catch (Error e)     
    {
        e.printStackTrace();
    }
    System.out.println("Not Terminated yet");
}
public void workonExceptions() throws Error 
{                                               
    try                                         
    {
        throw new Exception("Exception");
    }
    catch (Exception e) 
    {
        throw new Error("Exception Again");         }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:21:05+00:00Added an answer on June 5, 2026 at 5:21 am

    Some background on Error: It’s not intended to be catchable; it only comes up when something goes really wrong. An exception is meant to be caught and handled, since it’s something that may come up on occasion, but shouldn’t interrupt or interfere severely with the running of your program, such as dividing by zero.

    As for it working inside of a try...catch statement, the reason is that this is a property of the Throwable class.

    Only objects that are instances of this class (or one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement. Similarly, only this class or one of its subclasses can be the argument type in a catch clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know whether it is possible to have multiple stores under 1
Using Python, I want to know whether Java is installed.
I could have sworn that I've used NUnit's Assert.Throws to determine whether or not
Im creating an application and i want to know whether or not the browser
I want to know how can i determine whether an image is available on
I want to know whether this sentence is correct? You can do: var a
I have a problem. I need to know whether my page has global errors
I want to know whether it is possible to save as an array list
I want to know whether 301 redirect always preserve referrer. I make a page
I want to know whether it is possible to commit to a previous version.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.