UrbanPro

Learn Java Training from the Best Tutors

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

Search in

What are the different types of Exceptions in Java?

Asked by Last Modified  

10 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Computer Application

Null pointer exception ArrayOutOfIndex exception DivideByZero exception
Comments

Software Developer And Trainer

compile time exception and run time exception
Comments

Exception is an abnormal condition or error that arises during an application processing at run time. The parent class is the Throwable class which has two direct subclasses, java.lang.Error and java.lang.Exception. custom exception that extends the Exception class. The JVM takes care of throwing...
read more
Exception is an abnormal condition or error that arises during an application processing at run time. The parent class is the Throwable class which has two direct subclasses, java.lang.Error and java.lang.Exception. custom exception that extends the Exception class. The JVM takes care of throwing an instance of Error object when there is a system error. The proper Exception handling useful in tracking and debugging errors in the application and sub systems. All the exceptions, which are caught and handled within the calling method or declared in the throws clause of the method, are categorized under checked exceptions. All the checked exceptions must be a sub class of java.lang. Exception class. The JVM will verify that all the checked exceptions are taken care properly by the calling method in the class. Unchecked Exceptions The exception which are raised because of incorrect logic or programming errors are categorized as Unchecked exceptions. These exceptions are sub classes of RunTimeException class. The JVM will not verify for these exceptions in the calling method read less
Comments

1) Checked Exception The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions e.g.IOException, SQLException etc. Checked exceptions are checked at compile-time. 2) Unchecked Exception The classes that extend RuntimeException are known as unchecked exceptions...
read more
1) Checked Exception The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions e.g.IOException, SQLException etc. Checked exceptions are checked at compile-time. 2) Unchecked Exception The classes that extend RuntimeException are known as unchecked exceptions e.g. ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc. Unchecked exceptions are not checked at compile-time rather they are checked at runtime. 3) Error Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc. read less
Comments

Java,adv java,hibernate,spring

2 types of exceptions exception and error inside exception compile time exception(checked exception) and run time exception(unchecked exception)
Comments

Trainer

Main two types 1. Compile time exception ex: FileNotFound Exception,ClassNotFound Exception. 2. Run time exception ex: ArrayIndexOutOfBounds Exception,IllegalTypeException,NullPointer exception,Arithmetic exception. also called Checked exceptions and Unchecked exceptions.
Comments

Java/J2EE Expert & Data Analytic

An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore these exceptions are to be handled. An exception...
read more
An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore these exceptions are to be handled. An exception can occur for many different reasons, below given are some scenarios where exception occurs. A user has entered invalid data. A file that needs to be opened cannot be found. A network connection has been lost in the middle of communications or the JVM has run out of memory. Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner. Based on these we have three categories of Exceptions you need to understand them to know how exception handling works in Java, Checked exceptions: A checked exception is an exception that occurs at the compile time, these are also called as compile time exceptions. These exceptions cannot simply be ignored at the time of compilation, the Programmer should take care of (handle) these exceptions. For example, if you use FileReader class in your program to read data from a file, if the file specified in its constructor doesn't exist, then an FileNotFoundException occurs, and compiler prompts the programmer to handle the exception. import java.io.File; import java.io.FileReader; public class FilenotFound_Demo { public static void main(String args[]){ File file=new File("E://file.txt"); FileReader fr=new FileReader(file); } } If you try to compile the above program you will get exceptions as shown below. C:\>javac FilenotFound_Demo.java FilenotFound_Demo.java:8: error: unreported exception FileNotFoundException; must be caught or declared to be thrown FileReader fr = new FileReader(file); ^ 1 error Note: Since the methods read() and close() of FileReader class throws IOException, you can observe that compiler notifies to handle IOException, along with FileNotFoundException. Unchecked exceptions: An Unchecked exception is an exception that occurs at the time of execution, these are also called as Runtime Exceptions, these include programming bugs, such as logic errors or improper use of an API. runtime exceptions are ignored at the time of compilation. For example, if you have declared an array of size 5 in your program, and trying to call the 6th element of the array then an ArrayIndexOutOfBoundsExceptionexception occurs. public class Unchecked_Demo { public static void main(String args[]){ int num[]={1,2,3,4}; System.out.println(num[5]); } } If you compile and execute the above program you will get exception as shown below. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at Exceptions.Unchecked_Demo.main(Unchecked_Demo.java:8) Errors: These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation. read less
Comments

Tutor

you can say runtime and compile time, checked and uncheked exceptions.
Comments

Checked Exceptions and Unchecked exceptions
Comments

Teacher

Exceptions are 2 types. 1.Checked 2.Uncheked All the exception for that compiler doesn't care are comes under unchecked exception i.e. ArithmaticException, ArrayIndexOutofBoundexp etc Exceptions which needs to be defined in throws clause of a method r checked exception,ie.sevletException,ClassNotFoundExp,NoSuchFieldException...
read more
Exceptions are 2 types. 1.Checked 2.Uncheked All the exception for that compiler doesn't care are comes under unchecked exception i.e. ArithmaticException, ArrayIndexOutofBoundexp etc Exceptions which needs to be defined in throws clause of a method r checked exception,ie.sevletException,ClassNotFoundExp,NoSuchFieldException etc read less
Comments

View 8 more Answers

Related Questions

Please suggest some books to self-learn Java at home?
For self learning the best book is Core Java written by Gary Cornell and Kay Horstmann. This book comes in 2 volumes and both are important to learn the subject from the ground up to the advanced level.
Sharmistha
1 0
6
Can you use abstract and final both with a method? Why?
No because we have to provide an abstract method with implementation in the subclass (the child class of the parent class in which the abstract method was declared). And for providing this implementation...
Sushil
What is the difference between a C program execution and a Java program execution?
When we compile C program then it convert into exe file ie Machine language with the help of OS lib file which is platform dependent . If we compile java prgram then it convert into class file with the...
Kaushal
0 0
5
Which is the best IDE to write Java code?
Eclipse and intellige are the best IDE to write Java Code.
Akash

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

Ask a Question

Related Lessons

Big Data Hadoop Training
What is Big Data? Big data means really a big data, it is a collection of large datasets that cannot be processed using traditional computing techniques. Big data is not merely a data, rather it has become...

JAVA OOPs Concepts (Object-Oriented Programming System)
JAVA OOPs Concepts (Object-Oriented Programming System) It is primarily having below crucial points. Without below essential points, we will never be able to achieve OOPs in java, PHP, C#, etc. Now let...

Palindrome Number : Java Function
An easier way to find out whether a number is a Palindrome number or not. Eg. 121, 88, 12321 etc public boolean isPalindrome ( int n ) { int rev = 0, r; for( i = n; i > 0; i /= 10 ) { r...

Free selenium video tutorial
Hi All, Hope you are doing good. We uploaded few videos on Selenium components like IDE, RC and Webdriver on youtube channel you can watch them for free of cost. Kindly search with below link: ...
S

Java Overview
Java platform overview Java platform components The Java platform consists of the following components. The Java language Like any programming language, the Java language has its own structure, syntax...
A

Akshay Shende

0 0
0

Recommended Articles

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 >

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 >

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 >

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