what is the difference between throw and throws

What is the Actual difference

  • Sandesh Powar
  • Sandesh Powar
  • |
  • 20 Mar
  • |
  • 181 Views
  • |
  • 4 Answers

text limit upto 4000

  • 2

    Throw keyword is used in the method body to throw an exception, while throws is used in method signature to declare the exceptions that can occur in the statements present in the method.

    • Voted By:
    • Aleena ,
    • Sandesh

  • 1

    The throw keyword in Java is used to explicitly throw an exception from a method or any block of code.
    throws is a keyword in Java which is used in the signature of method to indicate that this method might throw one of the listed type exceptions.

    • Voted By:
    • Sandesh

  • 0

    Throw keyword is used to throw an exception explicitly. It is followed by an instance of an exception class.
    Throws keyword is used to declare an exception. It is followed by an instance of exception class.
    I hope it will clear your doubt. If you are sticking with some small issues, it would be best to brush up the knowledge and join java training institute in Delhi.
     


  • -2

    Java throw keyword is used to explicitly throw an exception whereas Java throws keyword is used to declare an exception.


Did Not Get The Answer? 
Contact people of Talent-Core Java directly from here