Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Assume you wish to create a mutator for a zip code instance variable within an Address data definition class. Instead of throwing IllegalArgumentException, you

1. Assume you wish to create a mutator for a zip code instance variable within an Address data definition class. Instead of throwing IllegalArgumentException, you wish to create your own exception, InvalidZipCodeException which will be thrown when an invalid zip code has been passed to the method. Using course terminology, describe (in detail) how you could create your own exception, InvalidZipCodeException. No Java code is needed, but you should be very specific in describing what would be included within the Java code, using course terminology.

2. Assume you have created an inheritance hierarchy with classes of Employee, Engineer, and Architect. Employee is an abstract class. Each class has a hello() method. Based on the implementation code provided below, could each of the following code blocks be added to the end of the main method? Why or why not? Explain your answer using course terminology.

1) JOptionPane.showMessageDialog(null, getHelloMessage(emp1));

2) JOptionPane.showMessageDialog(null, getHelloMessage(eng1));

3) JOptionPane.showMessageDialog(null, getHelloMessage(arc1));

// Implementation Class

import javax.swing.JOptionPane;

public class Question {

public static void main(String[] args) {

Employee emp1 = new Employee();

Engineer eng1 = new Engineer();

Employee arc1 = new Architect();

//Code would be added here

}

public static String getHelloMessage(Employee e) {

return e.hello();

}

}

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

What are Electrophoresis?

Answered: 1 week ago