Java OCA OCP Practice Question 536

Question

How many bytes does the following code write to file dest?

1. try { 
2.   FileOutputStream fos = new FileOutputStream("dest"); 
3.   DataOutputStream dos = new DataOutputStream(fos); 
4.   dos.writeInt(3); 
5.   dos.writeDouble(0.0001); 
6.   dos.close(); 
7.   fos.close(); 
8. } 
9. catch (IOException e) { } 
  • A. 2
  • B. 8
  • C. 12
  • D. 16
  • E. The number of bytes depends on the underlying system.


C.

Note

The writeInt() call writes out an int, which is 4 bytes long.

The writeDouble() call writes out a double, which is 8 bytes long.

The total is 12 bytes.




PreviousNext

Related