Java OCA OCP Practice Question 2146

Question

Which classes in the Java API provide both forms of the printf() method?

printf(String formatStr, Object... args)
printf(java.util.Locale l, String formatStr, Object... args)

Select the two correct answers.

  • (a) java.lang.String
  • (b) java.util.StringBuilder
  • (c) java.io.PrintStream
  • (d) java.io.PrintWriter
  • (e) java.util.Scanner
  • (f) java.util.Formatter
  • (g) java.util.Console


(c) and (d)

Note

Only the classes java.util.PrintStream and java.util.PrintWriter provide the printf() method.

The Console class only provides the first form.




PreviousNext

Related