nerdexam
GIAC

GSSP-JAVA · Question #83

Which of the following code snippets will read the eighth byte of the file wRead.txt into the variable str?

The correct answer is D. FileInputStream fis=new FileInputStream("wRead.txt"); fis.skip(7);int str=fis.read(). See the full explanation below for the reasoning.

Question

Which of the following code snippets will read the eighth byte of the file wRead.txt into the variable str?

Options

  • ARandomAccessFile raf=new RandomAccessFile("wRead.txt"); raf.seek(8);int
  • BFileInputStream fis=new FileInputStream("wRead.txt"); int str=fis.read(8);
  • CFileInputStream fis=new FileInputStream("wRead.txt"); fis.skip(8);int str=fis.read();
  • DFileInputStream fis=new FileInputStream("wRead.txt"); fis.skip(7);int str=fis.read();

How the community answered

(31 responses)
  • A
    16% (5)
  • B
    3% (1)
  • C
    10% (3)
  • D
    71% (22)

Community Discussion

No community discussion yet for this question.

Full GSSP-JAVA Practice