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 is 'this' in Java?
this is a keyword in Java. Works as a reference to current object whose constructor is being invoked
SEED Infotech Ltd
Which programming language should I learn, C++, Python or Java?
It depend on your interest , meanwhile phython is the new boss. Java is evergreen
Navneet
0 0
5
What is serialization?
serialization is a storing the state of the object into the file
Shubham
Please tell me what Object Oriented Programming and Object Based Programming with reallife example..what is the difference between them.?
Hi Ritesh, In order to be a true object oriented programming language, following 4 need to be present… 1) Abstraction - Hiding the implementation details from the user, only the functionality will...
Ritesh
hat is java
Introduction to JAVA Programming concepts of Basic Java Language Features Data Types, Variables Control Statements OOPS Concepts Writing your own Java Classes Object...
Narendra
0 1
8

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

Ask a Question

Related Lessons

Why we need to learn Programming languages?
Language is medium for communication. If two parties like to communicate or exchange the thoughts they must know a language. Language should be understandable by both the Parties. For example A wants to...

Fractional Knapsack
Algorithm - Fractional Knapsack import java.util.Scanner; public class Knapsack01 { public static void main(String args) { Scanner scan = new Scanner(System.in); int...

CoreJAVA
Core Java Training High Level Course Content Trained by Java Architect 1. Core Java Programming Introduction of Java 2. Data types and Operators 3. Control Flow statements 4. OOPS and its application...
A

Overloading in JAVA
When a class contains more than one method with the same method name but different argument types, then it is called Overloading. Methods are said to be Overloaded methods. Also, know as Compile time...

How can everyone prepare to clear any Java interview?
Java interview your java should be much strong then J2EE. core java and Advance java is the basic foundation for Interview. Some of the topic about which you should know before going for a java interview...

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