#76 What is Exception in Java

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

For More Queries WhatsApp or Call on : +919008963671

Udemy Courses:

In this lecture we are discussing about Exception:
-- In java three types of errors that can occur during the execution of a program
i) compile time error
ii)logical error
iii) run time error -- this can be called as Exception
i)
Compile-time errors:
Compile-time errors are errors that occur during the compilation of the Java code.
These errors are caused by syntax errors, missing semicolons, or incorrect variable names,
among other things. If there are compile-time errors in your Java program, it cannot be compiled into bytecode,
and it cannot be executed.

ii)
Logical errors:
Logical errors are errors that occur when the program runs correctly, but it does not produce the expected output.
These errors occur because of a mistake in the program's logic. For example, if a program is supposed to add two numbers
but instead multiplies them, it will produce the wrong output. Logical errors are more difficult to detect than compile-time
errors because the program runs without any error messages.

Exceptions(Runtime error)
Exceptions are errors that occur during the execution of the Java program.
Exceptions occur when something unexpected happens, such as trying to read from a file that does not exist or dividing by zero.
When an exception occurs, the program will terminate unless the exception is handled by an exception handler.

In Exception we have Checked and Unchecked Exception this topic is discussed in Exception hierarachy:
a)
Checked Exception:
Checked exceptions are exceptions that the Java compiler requires you to handle or declare.
These exceptions are checked at compile time, and you must either handle the exception with a try-catch block or declare it with a throws clause.
If you do not handle or declare a checked exception, the code will not compile. Checked exceptions are typically related to input/output operations,
such as file handling or network communication.

b)
Unchecked Exception:
unchecked exceptions are exceptions that are not checked at compile time. These exceptions are typically caused by programming errors,
such as null pointer exceptions, array index out of bounds exceptions, and class cast exceptions. Unchecked exceptions are not required
to be handled or declared, but they can still occur during runtime.

Important:
both checked and unchecked exceptions can occur during runtime, but checked exceptions are checked at compile time and require handling
or declaring, while unchecked exceptions are not checked at compile time and do not require handling or declaring.


More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

Thanks for the description. It saves a lot of time for me to search and look for the definition of each and every topic.Sometimes description may have a lot more content than the video 😂. Anyways, the explanation is great in the video as well as the definition for them is pakka in the description. Ppl don't miss out the description.

sakthipriya
Автор

What is the difference between compile time error and checked exception

akshayaap
Автор

Small correction comes under compile time exception. You explained it as RunTimeException

saimanideepkuna
Автор

Bro, this course does not include file handling topics

avijit
Автор

Hi Sir greates videos as always.What is the application you using to write notes?

bikosankara
Автор

sir, ,
I have a question about java program language .i'm getting so many so many error in capital and small letter while writing a program in java .i'm not understanding that whether i need to buyhat that syntax or i need to understand i don't know what to do .. can u give me your valuable answer i'm kindly requesting you

banothnagesh
Автор

Are your videos ad free cause am not seeing any

architsrivastava
Автор

I am getting error: main method not found in class even i typed correctly or to extend the in vs code what to do

vinny