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 method can NOT be called directly in Java?

  1. main()

  2. finalize()

  3. System.gc()

  4. private methods of the same class

The correct answer is: finalize()

Finalize() is the only option that cannot be called directly in Java. This is because finalize() is used by the garbage collector to free up memory resources and cannot be called explicitly in the code. All other methods, including main(), System.gc(), and private methods of the same class, can be called directly in Java.