Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


What does polymorphism allow in object-oriented programming?

  1. Objects to change their type at runtime

  2. A single interface to be used for different underlying forms of data

  3. For objects to exist in multiple states simultaneously

  4. For objects to automatically delete themselves once they are no longer needed

The correct answer is: A single interface to be used for different underlying forms of data

Polymorphism allows for a single interface to be used for different underlying forms of data. This means that although an object may have many different forms or classes, it can be used interchangeably through a common interface. Option A is incorrect because objects cannot change their type at runtime. Once an object is created, its type is fixed and cannot be changed. Option C is also incorrect because objects cannot exist in multiple states simultaneously. Objects can only have a single state at any given time. Option D is incorrect because objects do not automatically delete themselves. The programmer is responsible for managing the memory of the objects they create.