rhiannonlm3118 rhiannonlm3118
  • 14-07-2019
  • Computers and Technology
contestada

What is the difference between the throw statement and the throws clause?

Respuesta :

Branta Branta
  • 21-07-2019

Answer:

throw and throws represent different constructs in Java programming language.

Explanation:

throw is used to explicitly throw an Exception from within a code segment.

For example:

public void throw_test(String str){

        if(str==null) throw new NullPointerException();

}

throws is used to specify an exception list which may be thrown by a method:

For example:

public String readFromFile(File f) throws IOException {

.....

// Some code fragment which could throw a IOException

}

Answer Link

Otras preguntas

explain how you can use base ten block to find 2.16÷3
Cara was using her calculator to solve a problem. The answer that displayed was 1.6E+12. She knows that she entered all of the numbers correctly. Why did the ca
what is the joining of a sperm and a egg called
$33. Of 75% what number? >.
Where would you look to find out how distances on a map compare to the actual distances on land?
What is 2x-y=-1 3x-2y=1
The two bones of the lower arm are _____.
what findings led Thomson to infer that particles that are smaller than atoms do exist?
Which are achievements of the Han dynasty? Choose all answers that are correct. A. smart, virtuous men in government administration B. cylinder seals for preser
A group of roommates decide to split the cost of a new sofa. If s is the cost of the sofa and n is the number of roommates, the formula c= s/n determines each