What an upcast does and does not change

A Java music app defines the following classes and then executes Media m = new Song();.


Java
class Media {
    String describe() { return "media"; }
}
class Song extends Media {
    String describe() { return "song"; }
    int bpm() { return 120; }
}


Select all of the statements below that are true.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Type Conversion and Casting Questions: