What does the following code fragment print out at line 9?
1. FileOutputStream fos = new FileOutputStream("xx"); 2. for (byte b=10; b<50; b++) 3. fos.write(b); 4. fos.close(); 5. RandomAccessFile raf = new RandomAccessFile("xx", "r"); 6. raf.seek(10); 7. int i = raf.read(); 8. raf.close() 9. System.out.println("i = " + i);
B.
All the code is perfectly legal, so no exceptions are thrown.
The first byte in the file is 10, the next byte is 11, the next is 12, and so on.
The byte at file position 10 is 20, so the output is i = 20.