in Education by
Which of these values is returned by read() method is end of file (EOF) is encountered? (a) 0 (b) 1 (c) -1 (d) Null This question was addressed to me by my college director while I was bunking the class. Question is taken from Reading & Writing Files in portion I/O & Applets of Java Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Right option is (c) -1 The best explanation: Each time read() is called, it reads a single byte from the file and returns the byte as an integer value. read() returns -1 when the end of the file is encountered.

Related questions

0 votes
    Which of these methods are used to read in from file? (a) get() (b) read() (c) scan() (d) readFileInput( ... I/O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which exception is thrown by read() method? (a) IOException (b) InterruptedException (c) SystemException (d) ... Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these exception is thrown by close() and read() methods? (a) IOException (b) FileException (c) ... & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these is used to read a string from the input stream? (a) get() (b) getLine() (c) read() (d) ... chapter I/O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these class is used to read characters and strings in Java from console? (a) BufferedReader (b) ... & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these class contains the methods used to write in a file? (a) FileStream (b) FileInputStream (c) ... & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these exception is thrown in cases when the file specified for writing is not found? (a) IOException (b ... & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these classes are used by Byte streams for input and output operation? (a) InputStream (b) ... Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these classes are used by character streams for input and output operations? (a) InputStream (b) Writer ... & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these is used to perform all input & output operations in Java? (a) streams (b) Variables (c) classes ... O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these is a type of stream in Java? (a) Integer stream (b) Short stream (c) Byte stream (d) Long ... I/O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these functions is called to display the output of an applet? (a) display() (b) paint() (c) ... /O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these methods can be used to output a string in an applet? (a) display() (b) print() (c) drawString( ... I/O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these methods is a part of Abstract Window Toolkit (AWT) ? (a) display() (b) paint() (c) drawString( ... I/O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a ... O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
...