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.


Which class is not directly derived from the Component class?

  1. JButton

  2. JLabel

  3. JFrame

  4. JTextField

The correct answer is: JFrame

The Component class is the root of all different types of user interface components in Java Swing, such as JButton, JLabel, and JTextField. These components inherit from the Component class and add additional functionalities specific to their type. However, JFrame is not directly derived from the Component class. Instead, it inherits from the Container class, which itself inherits from the Component class. This allows the JFrame class to have the ability to contain and organize other components. Therefore, option C is the correct answer as it is not directly derived from the Component class.