Which of the methods below is a correct implementation of the functionality described in this Javadoc comment? /** * This method returns a value that is twice as large as the provided * integer argument. * * @throws IllegalArgumentException if the provided number is negative. */   Group of answer choices public int increase1(int number) throws IllegalArgumentException { return number * 2; }   public int increase(int number) { try { if (number < 0) { throw new IllegalArgumentException(); } else { return number * 2; } } catch (IllegalArgumentException e) { System.out.println("Negative number!"); } }   public int increase(int number) { if (number < 0) { throw new IllegalArgumentException(); } return number * 2; } public int increase(int number) { if (number >= 0) { return number * 2; } else { return IllegalArgumentException; }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
100%

Which of the methods below is a correct implementation of the functionality described in this Javadoc comment?

/** * This method returns a value that is twice as large as the provided * integer argument. * * @throws IllegalArgumentException if the provided number is negative. */

 

Group of answer choices
public int increase1(int number) throws IllegalArgumentException { return number * 2; }

 

public int increase(int number) { try { if (number < 0) { throw new IllegalArgumentException(); } else { return number * 2; } } catch (IllegalArgumentException e) { System.out.println("Negative number!"); } }

 

public int increase(int number) { if (number < 0) { throw new IllegalArgumentException(); } return number * 2; }
public int increase(int number) { if (number >= 0) { return number * 2; } else { return IllegalArgumentException; } }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,