In Java, how can you check if a file or directory exists using the `File` class?
A. By using the `createNewFile()` method
B. By using the `read()` method
C. By using the `exists()` method
D. By using the `write()` method
Select an option to see the answer and solution.
Which method is used to delete a file or directory in Java?
A. `erase()`
B. `delete()`
C. `discard()`
D. `exit()`
Select an option to see the answer and solution.
In Java, what is the purpose of the `File.separator` constant?
A. It represents the parent directory
B. It represents the current directory
C. It represents the platform-specific file separator (e.g., `/` or ``)
D. It represents the ASCII value of the separator character
Select an option to see the answer and solution.
What is the difference between character streams and byte streams in Java?
A. Character streams are used for reading and writing binary data, while byte streams are used for text data
B. There is no difference between character streams and byte streams
C. Character streams are more efficient than byte streams
D. Character streams are used for reading and writing text data, while byte streams are used for reading and writing binary data
Select an option to see the answer and solution.
In Java, what is the purpose of the `BufferedWriter` class?
A. It is used to write character data to a file efficiently
B. It is used to write binary data to a file
C. It is used to read character data from a file
D. It is used to read binary data from a file
Select an option to see the answer and solution.
Which class is used for reading character streams in a platform-independent way in Java?
A. `BufferedReader`
B. `DataInputStream`
C. `FileReader`
D. `InputStreamReader`
Select an option to see the answer and solution.
In Java, what is the primary purpose of the `PrintStream` class?
A. It is used to read binary data from a file
B. It is used to write binary data to a file
C. It is used to write formatted text to an output stream
D. It is used to read text data from the keyboard
Select an option to see the answer and solution.
What is the difference between reading and writing character streams in Java?
A. Both reading and writing character streams use `InputStream` classes
B. Reading character streams use `Reader` classes, while writing character streams use `Writer` classes
C. Both reading and writing character streams use `OutputStream` classes
D. Writing character streams use `InputStream` classes
Select an option to see the answer and solution.
In Java, which class is used to read binary data from an input stream?
A. `PrintStream`
B. `BufferedReader`
C. `DataInputStream`
D. `FileInputStream`
Select an option to see the answer and solution.
What is the purpose of the `Console` class in Java?
A. It provides methods for reading and writing binary data
B. It provides methods for creating directories
C. It provides methods for performing mathematical operations
D. It provides methods for reading and writing character-based console input and output
Select an option to see the answer and solution.
System class is defined in .................
A. java.util package
B. java.lang package
C. java.io package
D. java.awt package
E. None of these
Select an option to see the answer and solution.
try{
File f = new File("a.txt");
}catch(Exception e){
}catch(IOException io){
}
Is this code create new file name a.txt ?
A. true
B. false
C. Compilation Error
D. None of these
Select an option to see the answer and solution.
Which of these classes defined in java.io and used for file-handling are abstract?
A. InputStream
B. PrintStream
C. Reader
D. FileInputStream
E. FileWriter
A. Only A
B. Only C
C. A and C
D. B and D
E. A, B and E
Select an option to see the answer and solution.
When comparing java.io.BufferedWriter and java.io.FileWriter, which capability exist as a method in only one of two ?
A. closing the stream
B. flushing the stream
C. writting to the stream
D. writting a line separator to the stream
E. None of these
Select an option to see the answer and solution.
What does AWT stands for?
A. All Window Tools
B. All Writing Tools
C. Abstract Window Toolkit
D. Abstract Writing Toolkit
Select an option to see the answer and solution.
Which of these is used to perform all input & output operations in Java?
A. streams
B. Variables
C. classes
D. Methods
Select an option to see the answer and solution.
Which of these is a type of stream in Java?
A. Integer stream
B. Short stream
C. Byte stream
D. Long stream
Select an option to see the answer and solution.
Which of these classes are used by Byte streams for input and output operation?
A. InputStream
B. InputOutputStream
C. Reader
D. All of the mentioned
Select an option to see the answer and solution.
Which of these classes are used by character streams for input and output operations?
A. InputStream
B. Writer
C. ReadStream
D. InputOutputStream
Select an option to see the answer and solution.
Which of these class is used to read from byte array?
A. InputStream
B. BufferedInputStream
C. ArrayInputStream
D. ByteArrayInputStream
Select an option to see the answer and solution.