Multiple choice technology programming languages

What is the result of compiling and running the following program? import java.util.Formatter; class Format2 { public static void main(String[] args) { String s="hello123"; Formatter f=new Formatter(); f.format("%S",s); System.out.println(f); } }

  1. Prints "hello123"

  2. Prints "HELLO123"

  3. Compiler error

  4. IllegalFormatException

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The %S format specifier in Java's Formatter class converts the string to uppercase. The format() method modifies the Formatter's internal content, and println(f) outputs the formatted result 'HELLO123'.