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 inheritance in Java?

View

2. Which keyword is used to inherit a class in Java?

View

3. Which of the following class types cannot be inherited?

View

4. What is the relationship between a parent class and a child class?

View

5. Which of the following statements is true about inheritance?

View

6. What does the super keyword do in Java?

View

7. Consider the following code. What will be printed?

View

8. Which type of inheritance is not supported in Java?

View

9. What happens if a parent class method is declared as final?

View

10. How can you prevent a class from being inherited?

View

1. What is inheritance in Java?

A method to hide implementation details.
A mechanism to acquire the properties of another class
A way to override methods in the same class.
None of the above.

2. Which keyword is used to inherit a class in Java?

extends
implements
inherits
super

3. Which of the following class types cannot be inherited?

Abstract class
Final class
Interface
Static class

4. What is the relationship between a parent class and a child class?

Has-A
Is-A
Uses-A
Does-A

5. Which of the following statements is true about inheritance?

Inheritance supports code reuse.
Child classes cannot override parent methods.
Java does not support multiple inheritance through classes.
Both A and C.

6. What does the super keyword do in Java?

It refers to the current class object.
It is used to access methods of a parent class.
It is used to inherit multiple classes.
It is used to define an abstract method.

7. Consider the following code. What will be printed?

<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

8. Which type of inheritance is not supported in Java?

Single
Multilevel
Multiple through classes
Hierarchical

9. What happens if a parent class method is declared as final?

It can be overridden in the child class.
It cannot be overridden in the child class.
It can only be called using the child class object.
None of the above.

10. How can you prevent a class from being inherited?

By using the static keyword.
By using the final keyword.
By using the abstract keyword.
By using the private keyword.