164k views
0 votes
Assume that processor refers to an object that provides a void method named process that takes no arguments. As it happens, the process method may throw one of several exceptions. Write some code that invokes the process method provided by the object associated with processor and arrange matters so that if process throws any exception, your code prints the message "process failure" to standard output and does nothing else in regard to the exception.

User DannyMo
by
8.1k points

1 Answer

3 votes

Answer:

Following are the code in the Java Programming Language:

try{ //try block.

processor.process(); // call the function through the object.

}

catch(Exception e){ //catch block .

System.out.println( "process failure"); //if any exception occurs then print.

}

Step-by-step explanation:

In the following code, we set two blocks in Java Programming Language of the exception handling which is try block or catch block.

  • In try block we call the function "process()" through the "processor" object.
  • If any exception occurs in the program then the catch block print the following message is "process failure"
User Andypaxo
by
8.6k points