Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q61: How does Java handle memory management for objects?
- A: Through explicit memory allocation
- B: Through garbage collection
- C: By manually freeing memory
- D: By using pointers
View Answer
B
Q62: What is the result of setting s3.setRollNo(-10); in the Student class example?
- A: The roll number will be set to -10
- B: The roll number will remain unchanged
- C: The roll number will be set to 100
- D: The roll number will be set to 0
View Answer
C
Q63: What is a characteristic of static variables in Java?
- A: They are shared among all instances of the class
- B: They are unique to each instance
- C: They can be modified by any object
- D: They are not accessible without an object
View Answer
A
Q64: What is the main use of a copy constructor in Java?
- A: To initialize an object from another object
- B: To destroy an object
- C: To print object details
- D: To set default values for attributes
View Answer
A
Q65: What is the primary purpose of inheritance in Java?
- A: Code reusability
- B: Code encapsulation
- C: Code optimization
- D: Code debugging
View Answer
A
Q66: In Java, which keyword is used to indicate inheritance?
- A: extends
- B: inherits
- C: super
- D: this
View Answer
A
Q67: How many classes can a Java class directly inherit from?
- A: One
- B: Two
- C: Multiple
- D: None
View Answer
A
Q68: Which Java class is the root of all other classes?
- A: Object
- B: Employee
- C: Teacher
- D: Manager
View Answer
A
Q69: What must be the first statement in a subclass constructor if calling a superclass constructor?
- A: a method call
- B: a return statement
- C: a super() call
- D: a this() call
View Answer
C
Q70: How does Java handle method overriding in subclasses?
- A: All methods are overridden by default
- B: Methods need to be explicitly marked
- C: Methods are overridden only if the subclass method has the same name and parameters
- D: Methods cannot be overridden
View Answer
C