Question: Given that Integer and Long are direct subclasses of Number, what type can be used to fill in the blank in the following class to
Given that Integer and Long are direct subclasses of Number, what type can be used to fill in the blank in the following class to allow it to compile?

A. Long
B. Integer
C. Long or Integer
D. Long or Number
E. Long, Integer, or Number
F. None of the above
package orchestra; interface MusicCreator { public Number play(); } abstract class StringInstrument { public Long play() {return 3L;} } public class Violin extends StringInstrument implements MusicCreator { play() { } public } return null;
Step by Step Solution
3.31 Rating (163 Votes )
There are 3 Steps involved in it
In this scenario were looking at Javas type system and how Javas inheritance and interface implementation rules apply when overriding a method Given that StringInstrument is an abstract class with a method play that returns Long and MusicCreator is an interface with a method play that returns Number the Violin class which extends StringInstrument and implements MusicCreator must implement ... View full answer
Get step-by-step solutions from verified subject matter experts
