Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write in java language Quickly plz Invalid SalaryException Employee -name: String -Salary: double +Employee(String, double) +set Salary(double): void +Invalid SalaryException() +Invalid SalaryException(String) 1. Implement a

image text in transcribed

write in java language Quickly plz

Invalid SalaryException Employee -name: String -Salary: double +Employee(String, double) +set Salary(double): void +Invalid SalaryException() +Invalid SalaryException(String) 1. Implement a user defined exception class called Invalid SalaryException. The class Must have two constructors, a constructor that takes no parameters, and a constructor that takes a string message. These constructors should call the corresponding constructors from the class java.lang. Exception. 2. Implement the class Employee, as follows: public void set Salary(double sal This method throws Invalid Salary Exception if the value of salis an less than zero. Otherwise, it sets the salary attribute to sal. You should change the Method signature to include the corresponding throws expression. ii.) public Employee(String name, , double salary This constructor initializes the class attributes this.name and this.salary appropriately. Implement a Main Method in the class Employee, as follows: a. Add a try-catch-finally blocks. The try block must include the following statements: 1. Create and instantiate an object of type Employee. 2. Call the method set Salary() on the object, where the actual parameter is 400. b. The catch block should catch Invalid SalaryException, and should call ther Method printStackTrace(): C. The finally block should print the string: "end of program execution

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions