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

 I want to learn from beginning, please tell me what is the best source to learn (core java)

hi sunaini It is very good that you want to learn programming... I would recommend you c,c++,java and dotnet courses...for becoming a good provrammer.. we provide online training..at lowest prices if...
Sunaini
If a class contains only a private constructor and no other constructor, is it possible to create object of that class? If yes how?
Yes, It is possible. But, Object can be created only with in that class (either in any method or block).
Shabbir
Why do many software engineers not like Java?
Opinions on programming languages can vary, but some software engineers may express dissatisfaction with Java for reasons such as perceived verbosity, boilerplate code, and a slower pace of language evolution...
Guruprasad
0 0
5
How to find a good Java coaching centre?
Its all depends on the trainer and his expertise. I would suggest you to get feedback from the students who already joined.
Abirami
1 0
6
Does Java support pointers?
Yes and no. . The pointer model is of course supported by Java. But it has become much easier to the developer to handle it. Because Java exposes the concept of pointer in terms of reference variables...
Santosh
0 0
7

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

Ask a Question

Related Lessons

Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

Design Pattern
Prototype Design Pattern: Ø Prototype pattern refers to creating duplicate object while keeping performance in mind. Ø This pattern involves implementing a prototype interface which tells...

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

Create Immutable Class
Snippet of an Immutable Class: package com.stringhr; /*Declare the class as 'final'. This would prevent any other class from extending it and hence from overriding any method from it which could modify...

Software Development Training In Jaipur
Satyam Web Solution provides website designing &development and software designing &development training in Jaipur for various stream’s students. MCA 6 month Industrial Training/Internship B....

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