Verified Solutions
What is the main advantage of using inheritance in Java?
✔✔A) It allows code reuse and reduces redundancy
B) It prevents classes from being modified
C) It forces all methods to be static
D) It removes the need for constructors
Which keyword is used to create a subclass in Java?
A) implements
B) extends
✔✔C) extends
D) inherits
What happens if a subclass has a method with the same signature as its superclass?
✔✔A) It overrides the superclass method
B) It causes a compilation error
C) The superclass method is automatically deleted
1
,D) The subclass method is ignored
Which access modifier allows a method to be accessed in the same package and by subclasses?
A) private
✔✔B) protected
C) default
D) public
What is method overriding in Java?
✔✔A) Redefining a method in a subclass with the same signature as in the superclass
B) Defining multiple methods with the same name but different parameters
C) A method that cannot be modified
D) A method that is only accessible within its class
Which of the following statements about super keyword is correct?
A) It refers to the current instance of the class
B) It is used to call a method from the same class
✔✔C) It is used to call the parent class’s constructor or method
2
, D) It prevents method overriding
What happens if a subclass does not explicitly call the superclass constructor?
A) The program will not compile
B) The superclass constructor is ignored
✔✔C) The default constructor of the superclass is called automatically
D) The subclass constructor cannot execute
Which of the following is true about final methods?
A) They can be overridden by subclasses
B) They must be declared as static
✔✔C) They cannot be overridden by subclasses
D) They must not have parameters
What is polymorphism in Java?
✔✔A) The ability of a method to take different forms in different contexts
B) The process of converting primitive data types into objects
C) The process of creating new objects from a class
3