what is difference between throw and throws in exception?

Answer Posted / arun

throw is used to throw an exception manually when we feel
that particular line of code in our program is going to
throw an exception
throw new MyException("exception")

throws is used instead of try and catch block,if we are not
using try and catch block and we know that our program is
going to throw an exception than we use throws key word

public void myExecption() throws Exception

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is empty list java?

525


What is queue in java?

557


What are the states of thread in java?

518


What makes a function well defined?

525


Explain wrapper classes in java?

537






how to open and edit XML file in Weblogic???

1552


What do you mean by stream pipelining in java 8?

742


Name container classes in java programming?

598


How do you generate random numbers in java?

520


What are the six ways to use this keyword?

610


Can we create an object of static class in java?

598


What is a key in java?

505


What is better- service oriented or batch oriented solutions?

1537


What are the types of literals?

567


What is passing parameters in java?

526