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

public class X { public static void main(String [] args) { X x = new X(); X x2 = m1(x); /* Line 6 */ X x4 = new X(); x2 = x4; /* Line 8 */ doComplexStuff(); } static X m1(X mx) { mx = new X(); return mx; } } After line 8 runs. how many objects are eligible for garbage collection?
Only one. After line 8 the original object referred to by x2 is dereferenced and ready for garbage collection. In m1(), mx ignores the object passed as argument and refers to a new object which is returned.
Srikanth
What is difference between C language and Java language?
C is more procedure-oriented while JAVA is data-oriented. Java is an Interpreted language while C is a compiled language. C uses the top-down {sharp & smooth} approach while JAVA uses the bottom-up...
Poonam
0 0
5

I am a fresher and I want to become a Java developer, so what is necessary to crack the Java interview ? 

For an interview, you should prepare all the basic questions of Java , class, function and OOP concepts.
Dipesh
What should I do after learning Java core?
After learning Java SE you should focus on building something to make your concepts clear. You can also learn Java related frameworks like Spring to build web applications.
Kumarnaik
0 0
5
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

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...

Free selenium video tutorial
Hi All, Hope you are doing good. We uploaded few videos on Selenium components like IDE, RC and Webdriver on youtube channel you can watch them for free of cost. Kindly search with below link: ...
S

Overview on Auto IT and use in selenium webdriver
AutoIt v3 is a freeware BASIC-like scripting languages designed for automating the windows GUI and general scripting. It used a combination of simulated keystrokes, mouse movements and window/control manipulation...
S

Java Advantages
In this video, learn about Java and its advantages. Also, check out the difference between Java and C++, Java development kit, Java Run Time Environment (JRE) with a proper demonstration program for better clarity.

Simple Input and Output in CoreJava
We can use any of the following options based on the requirements to accept data from the user in corejava and show them Integer Input Output Character Input Output Float Input Output INPUT AND...

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