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 Java feature allows for specifying the type in a class?

  1. Inheritance

  2. Generics

  3. Polymorphism

  4. Encapsulation

The correct answer is: Generics

Generics is the correct answer as it allows for specifying the type in a class. Inheritance, polymorphism, and encapsulation are all fundamental concepts in Java, but they do not involve explicitly specifying the type in a class. Inheritance allows for one class to inherit properties and methods from a parent class, polymorphism allows for objects to take on different forms and behaviors, and encapsulation is the practice of hiding data within a class and only allowing access to it through methods.