Consider the following program:
public class Main{ public static void main(String []args) { int c = 'a'; float f = 10; long ell = 100L; System.out.printf("char val is %c, float val is %f, long int val is %ld \n", c, f, ell); } }
Which one of the following options best describes the behavior of this program when executed?
a) prints: char val is a, float val is 10.000000, long int val is 100. b) prints: char val is 65, float val is 10.000000, long int val is 100. c) prints: char val is a, float val is 10, long int val is 100L. d) prints: char val is 65, float val is 10.000000, long int val is 100L. e) prints: char val is 65, float val is 10, long int val is 100L. f) throws an exception of java.util.UnknownFormatConversionException: Conversion = 'l'.
f)
There is no format specifier for long int, and the same %d format specifier for int is used for long as well.
So, the format specifier %ld results in a runtime exception UnknownFormatConversionException.