UrbanPro

Learn Java Training from the Best Tutors

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

Search in

What is the purpose of using throws keyword in java?

Asked by Last Modified  

12 Answers

Learn Java

Follow 9
Answer

Please enter your answer

The throws statement is how you create an exception stack trace. There isn't much magic in java--it's not some underlying system mystery that creates an exception, it is simply a "Throw" statement, and therefore the last few entries in any stack trace will probably be throw. It's not JUST the last one...
read more
The throws statement is how you create an exception stack trace. There isn't much magic in java--it's not some underlying system mystery that creates an exception, it is simply a "Throw" statement, and therefore the last few entries in any stack trace will probably be throw. It's not JUST the last one because in many cases exception handling consists of something like this: try { do something that might cause an exception catch(ExpectedException e) { throw new DifferetnException(e); } This lets you change what type of exception it was or add a better textual description or even handle some of the exceptions while re-throwing the others. Because of this it is often the last few levels (and maybe some in-between) that are caused by the "Throw" statement. read less
Comments

Private Online Java Training by Exp Software Engineer

The 'throws' keyword is used to delegate the exception handling mechanism to the caller of the function. It is generally put in the function definition, thereby indicating to the caller of the function to handle it using try and catch. public static void fun() throws MyException { //code } public static...
read more
The 'throws' keyword is used to delegate the exception handling mechanism to the caller of the function. It is generally put in the function definition, thereby indicating to the caller of the function to handle it using try and catch. public static void fun() throws MyException { //code } public static void main (String args[]) { try { fun(); } catch { } } read less
Comments

Unlimited learning from classes 6 to 10 (Mathematics) and Programming languages (C,C++,Java)

Throws kW is used with method signature. With throws k/w exception is not handled. It should be handled with try catch block.With throws k/w checked exceptions can be propagated which can not be propagated with throw k/w.
Comments

Computer classes For Working professionals and studne of Engineering, MCA, Class 12,11 class 10

The keyword throws in Java is used to declare an exception. It is instruction to the programmer that exception may occur so make provision for exception handling so that normal flow can be maintained.
Comments

Trainer

throwing an exception explicitly
Comments

Tutor

If a function is not handling the exception throws clause can be added to the function signature. This includes the list of exceptions which can be thrown by the function
Comments

The throw keyword is used to throw an exception from within a method. When a throw statement is encountered and executed, execution of the current method is stopped and returned to the caller. Whereas the throws keyword is used to declare that a method may throw one or some exceptions.
read more

The throw keyword is used to throw an exception from within a method. When a throw statement is encountered and executed, execution of the current method is stopped and returned to the caller. Whereas the throws keyword is used to declare that a method may throw one or some exceptions.

 

read less
Comments

Salesforce Trainer

To Throw an exception
Comments

It is used to declare an exception. It gives an information to the programmer that there may occur an exception so it is better for the programmer to provide the exception handling code so that normal flow can be maintained. Exception Handling is mainly used to handle the checked exceptions. If there...
read more
It is used to declare an exception. It gives an information to the programmer that there may occur an exception so it is better for the programmer to provide the exception handling code so that normal flow can be maintained. Exception Handling is mainly used to handle the checked exceptions. If there occurs any unchecked exception such as NullPointerException, it is programmers fault that he is not performing check up before the code being used. read less
Comments

Computer Teacher

Throws may be used, if we want o execute block of segment of code within it i.r throws section. if error encountered and we wish to execute certain code for that error we can use throws not necessary but may be use for better response.
Comments

View 10 more Answers

Related Questions

What are the most important topics in Java interviews for a fresher?
OOPS Multithreding String Handling Execption Handling Collection Freamwork JDBC Servlet Jsp Spring core Moudle Spring MVC
Advaith
0 0
6
What is the difference between string, stringbuffer, stringbuilder?
String is immutable, means once you created a String you can not modify, Even if you try to it will create a new string for you and assign that to you. StringBuffer and StringBuilder are immutable, however...
Neha
Is it good to go for a Java coaching center and learn Java (with advanced Java) to improve my programming skills?
yes, Please check the Institute reviews and discuss with the tutor, what topics were covered in class. Ask about the practicals session and how many hours/duration of the course.
Gerda
0 0
5
Need to learn java....
You may contact me. I teach Java in great depth and with very firm building blocks.
Ajay

What are major difference between JAVA & Python? Where you would recommend to use JAVA and where need to use Python?

Python is one of the most used programming language than Java. With the recent Popularity of the Machine learning, Artificial intelligence and Data science Python takes the first place of the Top 5 programming...
Amit Kumar
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

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 >

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 >

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