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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started