Learn Throws Keyword in Java | EasyTechCode

Veröffentlicht am: 09 Juni 2022
auf dem Kanal: Java Source Code
31
3

#throwskeywordjava #javatutorial #java #javaprogramming #javabasic #javaforbeginners
In this video we learn about throws keyword in exception handling along sample example. Type program in notepad , compile and run java program.
Throws Keyword
_________________
It is used along with methods if it does not handle exception.
The caller of methods can handle that exception.
Throws clause can list the type of exception it may throw.
Throw exception explicitly.
It can throw either checked or unchecked exception.
syntax
______
Data type method_name(parameterlist) throws exception_list
{
// code for methods
}
Exception_list is the list of exceptions that the methods can throw.
Example program
_________________
class sample7
{
void methodone() throws ArithmeticException
{
throw new ArithmeticException("Easy Tech Exception");
}
}
class sample_throws
{
public static void main(String args[])
{
sample7 obj= new sample7();
try
{
obj.methodone();
}
catch(ArithmeticException e)
{
System.out.println(" Hello :"+e);
}
}
}
output:
_______
Hello :java.lang.ArithmeticException: Easy Tech Exception.

Other Video Link
________________
Exception Handlingg:    • Learn Exception Handling in Java | Try and...  
Usage of throw keyword:    • Learn Throw keyword in Java | EasyTechCode  
Exception Handling with multiple Catch block:    • Learn Exception Handling with Multiple Cat...  
How to compile and run java program in notepad
   • Learn How to Compile and Run Java |  EasyT...  
Program to print welcome to java:
   • Learn Simple Java Basics  
Inheritance Definition:    • Learn Inheritance in Java  | EasyTechCode  
Constructor in Java :    • Learn Java Constructor | EasyTechCode  
#JavaClassObject :    • Learn How to Create Object in Java |  Easy...  
Types of Constructor:    • Learn Java Constructor Types | EasyTechCode  
Overloading Methods:
   • Java Method Overloading Explained with Exa...  
Overriding Methods :    • Learn Java Overriding Method #java  
Super keyword :    • Learn Super Keyword | EasyTechCode  
Interfaces in Java:    • Learn Interface in Java | EasyTechCode  
Packages in Java:    • Learn Packages in Java | EasyTechCode  


Auf dieser Seite können Sie das Online-Video Learn Throws Keyword in Java | EasyTechCode mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Java Source Code 09 Juni 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 31 Mal angesehen und es wurde von 3 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!