Complete the code to print "Hello, World!" to the console.
System.out.[1]("Hello, World!");
The println method prints the text and moves to a new line.
Complete the code to format and print a floating-point number with two decimal places.
System.out.printf("%.[1]f", 3.14159);
The %.2f format specifier prints a floating-point number with two decimals.
Fix the error in the code to print an integer padded with zeros to width 5.
System.out.printf("%[1]d", 42);
The format specifier %05d pads the integer with zeros to make it 5 characters wide.
Fill both blanks to print a string left-aligned in a field of width 10.
System.out.printf("%[1][2]s", "Hi");
The %-10s format specifier prints the string left-aligned in a 10-character wide field.
Fill all three blanks to print a floating-point number right-aligned with width 8 and 3 decimals.
System.out.printf("%[1][2][3]f", 7.12345);
The format specifier %08.3f prints the number padded with zeros, width 8, and 3 decimals.