Question: slove it in java Lab problem 2: Create an exception class named MyException that extend a base class named Exception Design a constructor in your

slove it in java

Lab problem 2:

Create an exception class named MyException that extend a base class named Exception Design a constructor in your class that accepts a string value set it to the super class constructor to display the exception message. Create a main class named product. Write a method inside the class called productCheck(int weight) that accepts weight of the product. Inside the method, if the weight is less than 100 then throw an exception Product is invalid otherwise print the weight of the product. Inside the main method declare single object of the product class and call the productCheck() method to display the weight of the product.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!