Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q141: What is the purpose of the savePersons method in the AddressBook example?
- A: To load person records from a file
- B: To save person records to a file
- C: To delete person records
- D: To update person records
View Answer
B
Q142: How is data written to a file using PrintWriter?
- A: Using write() method
- B: Using print() method
- C: Using println() method
- D: Using append() method
View Answer
C
Q143: What should you do before closing file streams in Java I/O operations?
- A: Flush the streams
- B: Encrypt the data
- C: Open the file again
- D: Read additional data
View Answer
A
Q144: What must an abstract class in Java contain?
- A: Only abstract methods
- B: Only concrete methods
- C: At least one abstract method
- D: Only static methods
View Answer
C
Q145: What happens if a subclass does not provide implementations for all abstract methods of its superclass?
- A: It becomes a concrete class
- B: It can be instantiated
- C: It must be declared abstract
- D: It will compile with warnings
View Answer
C
Q146: What is the primary purpose of the calculateArea() method in the Shape class?
- A: To calculate the perimeter of shapes
- B: To calculate the area of shapes
- C: To display the shape
- D: To initialize shape properties
View Answer
B
Q147: In the Circle class example, which method provides the implementation for the abstract method calculateArea()?
- A: getArea()
- B: computeArea()
- C: calculateArea()
- D: area()
View Answer
C
Q148: Which keyword is used to define an interface in Java?
- A: class
- B: interface
- C: abstract
- D: enum
View Answer
B
Q149: What must a class do to implement an interface in Java?
- A: Declare it as abstract
- B: Provide definitions for all interface methods
- C: Extend another class
- D: Use implements keyword only
View Answer
B
Q150: What is the role of the print() method in the Printable interface?
- A: To initialize print properties
- B: To print a document
- C: To define a printing contract
- D: To read printed content
View Answer
C