Mastering Java 2025 – 400 Free Practice Questions to Pass the 'Thinking in Java' Exam

Question: 1 / 510

How can you create a class object if its constructor is private?

By inheriting the class

By creating an object in a subclass

By calling a public static method of the class meant for object creation

Creating a class object requires calling the constructor of the class. However, if the constructor is set to private, it cannot be called outside of the class. Therefore, options A and B are incorrect as they involve inheriting or subclassing the class, both of which still require calling the constructor. Option D is also incorrect as it provides a general statement without explaining why the constructor being private is significant. Option C is the correct answer as it suggests using a public static method of the class specifically designed for object creation, bypassing the private constructor restriction.

Get further explanation with Examzify DeepDiveBeta

You cannot create an object if the constructor is private

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy