11. What is the difference between method overloading and method overriding in Java?
12. Which keyword is used to declare a method that cannot be overridden in Java?
13. In method overriding, is it mandatory for the return type of the subclass method to be the same as the superclass method?
14. What is the purpose of the "super" keyword in method overriding?
15. What is the purpose of the "@Override" annotation in Java?
16. What is the result of the following code snippet?
class Parent {
void display() {
System.out.println("Parent");
}
}
class Child extends Parent {
void display() {
System.out.println("Child");
}
}
public class Main {
public static void main(String[] args) {
Child obj = new Child();
obj.display();
}
}
class Parent {
void display() {
System.out.println("Parent");
}
}
class Child extends Parent {
void display() {
System.out.println("Child");
}
}
public class Main {
public static void main(String[] args) {
Child obj = new Child();
obj.display();
}
}