Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q131: In the example code, what is the function of the flush() method?
- A: It closes the file
- B: It writes any buffered data to the file
- C: It opens a file for reading
- D: It reads data from the file
View Answer
B
Q132: Which method is used to read a line from a file in the example code?
- A: read()
- B: nextLine()
- C: readLine()
- D: getLine()
View Answer
C
Q133: How do you handle exceptions in Java I/O operations?
- A: By using try and catch blocks
- B: By ignoring errors
- C: By using finally block only
- D: By using assert statements
View Answer
A
Q134: What is the role of the FileWriter class in the given example?
- A: To write characters to a file
- B: To read characters from a file
- C: To compress file data
- D: To encrypt file data
View Answer
A
Q135: How is a BufferedReader initialized in Java?
- A: BufferedReader br = new BufferedReader(new FileReader("file.txt"));
- B: BufferedReader br = new BufferedReader();
- C: BufferedReader br = new BufferedReader("file.txt");
- D: BufferedReader br = new BufferedReader(new PrintWriter("file.txt"));
View Answer
A
Q136: In the provided code for ReadFileEx, what is the purpose of the while loop?
- A: To write data to the file
- B: To read and process each line from the file
- C: To open the file for reading
- D: To handle exceptions
View Answer
B
Q137: What is a node stream in Java I/O?
- A: A stream that provides additional functionality
- B: A stream that connects directly to a data source
- C: A stream that encrypts data
- D: A stream that manages network connections
View Answer
B
Q138: What is a filter stream in Java I/O?
- A: A stream that reads data from a file
- B: A stream that provides additional functionality on top of a node stream
- C: A stream that writes data to a file
- D: A stream that closes file connections
View Answer
B
Q139: What file format is used to save person records in the address book example?
- A: JSON
- B: XML
- C: CSV
- D: Text file
View Answer
D
Q140: What method is used to split a string into substrings in Java?
- A: split()
- B: tokenize()
- C: parse()
- D: divide()
View Answer
A