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

solve the inequality using the algebraic approach: x+2>3x-8
Which of the following is a chemical property of the noble gases? A.The boiling points are close together. B. The melting points are close together. C. They ar
What is the explicit formula for this sequence?
need help asap please
You notice that two brothers have the same eye color. You are describing their (2 points) genotype phenotype physotype genetic makeup
if you were a physicist trying to determine the gravitational constant and you were able to measure the force of gravity exerted between two objects their masse
What best explains how the supremacy clause is connected to federalism
what is subsistence farming and why is it important.
Is this reaction an oxidation reaction or a reduction? Al → Al3+ + 3e−
I’m geometry , “Line” is ___.