Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

1. What is polymorphism in Java?

View

2. Which of the following is an example of compile-time polymorphism?

View

3. Which keyword is used to achieve runtime polymorphism in Java?

View

4. What is the result of method overriding in Java?

View

5. Consider the following code. What will be the output?

View

6. What happens when a static method is overridden in Java?

View

7. Which of the following is true about method overloading?

View

8. Which of the following supports runtime polymorphism?

View

9. What is the main difference between overriding and overloading?

View

10. Which method is called when a child class object is created and assigned to a parent class reference?

View

1. What is polymorphism in Java?

<p><br></p><p><br></p>

The ability of an object to take on many forms.
Hiding implementation details.
Sharing code across multiple classes.
None of the above.

2. Which of the following is an example of compile-time polymorphism?

Method Overriding
Method Overloading
Dynamic Method Dispatch
None of the above

3. Which keyword is used to achieve runtime polymorphism in Java?

<p>A. this</p><p>B. static</p><p>C. super</p><p>D. No specific keyword<br><strong>Answer:</strong> D</p>

this
static
super
No specific keyword

4. What is the result of method overriding in Java?

Methods in the parent class are hidden.
Child class methods with the same name and signature replace the parent class methods.
Compilation error.
Runtime error.

5. Consider the following code. What will be the output?

<p>class A {<br>&nbsp; &nbsp; void display() {<br>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Class A");<br>&nbsp; &nbsp; }<br>}<br>class B extends A {<br>&nbsp; &nbsp; void display() {<br>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Class B");<br>&nbsp; &nbsp; }<br>}<br>public class Test {<br>&nbsp; &nbsp; public static void main(String[] args) {<br>&nbsp; &nbsp; &nbsp; &nbsp; A obj = new B();<br>&nbsp; &nbsp; &nbsp; &nbsp; obj.display();<br>&nbsp; &nbsp; }<br>}<br><br></p>

Class A
Class B
Compilation Error
Runtime Error

6. What happens when a static method is overridden in Java?

The child method replaces the parent method at runtime.
Static methods cannot be overridden.
The child method hides the parent method.
Compilation error.

7. Which of the following is true about method overloading?

The method names and parameter lists must be the same.
Methods with the same name but different parameter lists are considered overloaded.
Overloading is only possible in child classes.
Overloading can only be done with static methods.

8. Which of the following supports runtime polymorphism?

<p><br></p><p><br></p>

Abstract classes
Interfaces
Virtual functions
All of the above

9. What is the main difference between overriding and overloading?

<p><br></p><p><br></p>

Overriding occurs in the same class, while overloading occurs in different classes.
Overriding occurs between parent and child classes, while overloading occurs within the same class.
Overriding changes the parameter list, while overloading does not.
None of the above.

10. Which method is called when a child class object is created and assigned to a parent class reference?

<p><br></p><p><br></p>

The parent class method.
The child class method.
It depends on the method being static or not.
Compilation error.