Skip to content

Instantly share code, notes, and snippets.

@rayjcwu
Created January 20, 2014 06:55
Show Gist options
  • Save rayjcwu/8516073 to your computer and use it in GitHub Desktop.
Save rayjcwu/8516073 to your computer and use it in GitHub Desktop.
Which one of the following is a legal statement? 1. InventoryItem inv = new Perishable(); 2. Perishable p = new PRoduce(); 3. Produce p = new Fruit(); 4. Produce p = new Produce();
interface Perishable {
int daysRemaining();
}
class InventoryItem {}
abstract class Produce extends InventoryItem implements Perishable {}
class Fruit extends Produce {
@Override
public int daysRemaining() {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment