Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( a ) Consider the following classes: public class Bird { public int sp 2 ( Object o , Bird b ) { return 1

(a) Consider the following classes:
public class Bird {
public int sp2(Object o,
Bird
b){
return 1;
protected double sp2(Bird b){
return 2; }
int sp2(java.util.Scanner s){
return 3; }
private boolean sp2(int i){
return true; }
public int sp2(Object o,
String s){
return o.hashCode(); }
public int sp2(String s,
Object o){return
4;
}
}
public class Jay extends Bird {
public int sp2(String x,
String y)
{return 5; }
private int sp2(double d){
return 6; }
boolean sp2(Jay j, long i){
return true; }
protected long sp2(Jay j, int i){
return 7 ; }
public int sp2(Object sp2,
Bird b){return 8;
}
}
List the method signatures of methods named sp2 that are made available by
the public interface of class Jay.
(b) You are told by your boss to add runtime error checking to your code. When is
it better to throw an exception, and when is it better to use an assert statement?
For both cases, give a suitable example and explain why the chosen approach is
more appropriate for the example.
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions