Skip to main content

Web Design and Development MCQs with Answers

Practice important Web Design and Development MCQs with answers and explanations.

Chapter: 8
Q121:
Which of the following syntax is used to attach an input stream to the console?
A. FileReader fr = new FileReader(' input.txt ') ;
B. FileReader fr = new FileReader(FileDescriptor.in);
C. FileReader fr = new FileReader(FileDescriptor);
D. FileReader fr = new FileReader(console);
Correct Answer: B
Chapter: 8
Q122:
Window frame and dialog use ________ as their default layout.
A. Border layout
B. Flow layout
C. GridBag layout
D. Grid layout
Correct Answer: A
Chapter: 8
Q123:
There are _________ types of exceptions in Java
A. 2
B. 3
C. 4
D. 5
Correct Answer: A
Chapter: 8
Q124:
In the given code, what exception is caught by the catch block?
A. IOException
B. NullPointerException
C. FileNotFoundException
D. ArrayIndexOutOfBoundsException
Correct Answer: A
Chapter: 8
Q125:
Which block always executes, even if an exception is not thrown?
A. 'try'
B. 'catch'
C. 'finally'
D. 'throws'
Correct Answer: C
Chapter: 8
Q126:
What does the 'printStackTrace()' method do?
A. It prints the exception message
B. It prints the stack trace of the exception
C. It prints the exception name
D. It prints the exception description
Correct Answer: B
Chapter: 8
Q127:
What is the purpose of Java I/O streams?
A. To handle exceptions
B. To read and write data
C. To manage memory allocation
D. To compile Java code
Correct Answer: B
Chapter: 8
Q128:
Which class in Java is used to read data from a file?
A. FileReader
B. PrintWriter
C. BufferedReader
D. ObjectOutputStream
Correct Answer: A
Chapter: 8
Q129:
What does the BufferedReader class do in Java I/O?
A. Provides compression
B. Buffers input for efficient reading
C. Writes data to a file
D. Encrypts data
Correct Answer: B
Chapter: 8
Q130:
What is the purpose of the PrintWriter class in Java?
A. To write data to files
B. To read data from files
C. To buffer input data
D. To manage network connections
Correct Answer: A
Chapter: 8
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
Correct Answer: B
Chapter: 8
Q132:
Which method is used to read a line from a file in the example code?
A. read()
B. nextLine()
C. readLine()
D. getLine()
Correct Answer: C
Chapter: 8
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
Correct Answer: A
Chapter: 8
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
Correct Answer: A
Chapter: 8
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"));
Correct Answer: A
Chapter: 8
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
Correct Answer: B
Chapter: 8
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
Correct Answer: B
Chapter: 8
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
Correct Answer: B
Chapter: 8
Q139:
What file format is used to save person records in the address book example?
A. JSON
B. XML
C. CSV
D. Text file
Correct Answer: D
Chapter: 8
Q140:
What method is used to split a string into substrings in Java?
A. split()
B. tokenize()
C. parse()
D. divide()
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Web Design and Development

🚀 Start Quiz Now