Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Chapter: 9
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
Correct Answer:
B
Chapter: 9
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
Correct Answer:
C
Chapter: 9
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
Correct Answer:
A
Chapter: 9
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
Correct Answer:
C
Chapter: 9
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
Correct Answer:
C
Chapter: 9
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
Correct Answer:
B
Chapter: 9
Q147:
In the Circle class example, which method provides the implementation for the abstract method calculateArea()?
A. getArea()
B. computeArea()
C. calculateArea()
D. area()
Correct Answer:
C
Chapter: 9
Q148:
Which keyword is used to define an interface in Java?
A. class
B. interface
C. abstract
D. enum
Correct Answer:
B
Chapter: 9
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
Correct Answer:
B
Chapter: 9
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
Correct Answer:
C
Chapter: 9
Q151:
Which of the following statements about interfaces is true?
A. A class can implement multiple interfaces
B. Interfaces can have method implementations
C. Interfaces can be instantiated
D. Interfaces can contain instance variables
Correct Answer:
A
Chapter: 9
Q152:
What does the Speaker interface require its implementing classes to provide?
A. A speak() method with a default implementation
B. A print() method
C. A speak() method with implementation
D. A calculateArea() method
Correct Answer:
C
Chapter: 9
Q153:
What is the purpose of using interface-based polymorphism in Java?
A. To restrict the class hierarchy
B. To allow multiple inheritance
C. To prevent class instantiation
D. To achieve method overloading
Correct Answer:
B
Chapter: 9
Q154:
What is the output of the Test class in the Speaker interface example when sp points to Politician?
A. Web Design and Development Talks
B. Politics Talks
C. Sports Talks
D. Name: address
Correct Answer:
B
Chapter: 9
Q155:
In the code Shape s = new Circle();, what type is s?
A. Circle
B. Shape
C. Object
D. Test
Correct Answer:
B
Chapter: 10
Q156:
What type of method must a class provide when implementing an interface method?
A. Static method
B. Abstract method
C. Concrete method
D. Final method
Correct Answer:
C
Chapter: 10
Q157:
Which Java class cannot be instantiated directly?
A. Circle
B. Shape
C. Test
D. Student
Correct Answer:
B
Chapter: 10
Q158:
What will happen if a class does not implement all methods of an interface?
A. It will compile with a warning
B. It must be declared abstract
C. It will compile but with errors
D. It will execute with runtime exceptions
Correct Answer:
B
Chapter: 10
Q159:
What does the AWT stand for in Java?
A. Abstract Windowing Toolkit
B. Advanced Window Toolkit
C. Automatic Window Toolkit
D. Advanced Widget Toolkit
Correct Answer:
A
Chapter: 10
Q160:
An abstract class --------------- instantiated.
A. Can’t be
B. Can be
C. Must
D. None of these
Correct Answer:
A