102k views
3 votes
You can invoke the println and print methods on which object?

A. the HelloWorld object
B. the String class
C. any PrintStream object
D. any object in Java

1 Answer

4 votes

Final answer:

The println and print methods can only be invoked on any PrintStream object, such as System.out, which is a static member of the System class.

Step-by-step explanation:

The println and print methods can be invoked on any PrintStream object. In Java, the most commonly used PrintStream object is System.out, which is connected to the console. System.out is a static member of the System class and it is an instance of PrintStream. Therefore, the correct option is C. any PrintStream object. These methods cannot be directly invoked on a HelloWorld object unless it specifically contains them, the String class doesn't contain these methods, and not every object in Java has print or println methods.

User Kirill Volkov
by
7.3k points