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

history can someone help plzzz
how should a sterile package be handled
Graph y=15x+3. Question 2 Identify the x-intercept. x-intercept:
WILL MARK BRAINLIEST PLEASE HELP
What are the three branches of government found in early state constitutions? a Legislative, Executive, and Presidential b Legislative, Executive, and Congre
Brenna wants to borrow $21,000 to buy a used car. She examined her budget and decides that she can afford a payment of $375a month. If her bank offers her an AP
what is proportional to 26/13​
who wants to be freinds
PLEASE HELP ASAP describe how the equations for gravitational force and electrostatic force are similar
The properties of carbon atoms allow carbon to easily bond to other carbon atoms to form _____ and complex macromolecules with unique structures and special fun