Java OCA OCP Practice Question 2463

Question

Given:

37.  boolean b = false;  
38.  int i = 7;  
39.  double d = 1.23;  
40.  float f = 4.56f;  
41.  
42.  // insert code here 

Which line(s) of code, inserted independently at line 42, will compile and run without exception? (Choose all that apply.)

  • A. System.out.printf(" %b", b);
  • B. System.out.printf(" %i", i);
  • C. System.out.format(" %d", d);
  • D. System.out.format(" %d", i);
  • E. System.out.format(" %f", f);


A, D, and E

Note

A, D, and E have the correct conversion characters for their respective argument.

Remember that printf() and format() have the same functionality.

B is incorrect because integers should use %d.

C is incorrect because both floats and doubles should use %f.




PreviousNext

Related