Question: ( 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.
 (a) Consider the following classes: public class Bird { public int

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 Programming Questions!