0 votes
by (1.3k points)

1 Answer

0 votes
by (1.1k points)
  • CustomException class is the custom exception class this class is extending Exception class.
  • Create one local variable message to store the exception message locally in the class object.
  • We are passing a string argument to the constructor of the custom exception object. The constructor set the argument string to the private string message.
  • toString() method is used to print out the exception message.
  • We are simply throwing a CustomException using one try-catch block in the main method and observe how the string is passed while creating a custom exception. Inside the catch block, we are printing out the message.
Welcome to CodersEditor Q&A, where you can ask questions and receive answers from other members of the community.
...