Question 1 of 25
Hints left: 3
Q1
What is the purpose of the "@Override" annotation in Java?
Q2
In method overriding, is it mandatory for the return type of the subclass method to be the same as the superclass method?
Q3
In method overloading, can methods have the same name and the same parameter types if their access modifiers are different?
Q4
What is the purpose of the "@Override" annotation in Java?
Q5
What is the purpose of the "super" keyword in method overloading?
Q6
What happens when a subclass tries to override a static method from the superclass in Java?
Q7
What is the purpose of method overriding in Java?
Q8
What is the purpose of method hiding in Java?
Q9
Which method is called during method overriding in Java if the superclass method is invoked using the "super" keyword?
Q10
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) { Parent obj = new Child(); obj.display(); } }
Q11
In Java, what is the return type of a method that does not return any value?
Q12
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(); } }
Q13
In Java, can a subclass overload a method from its superclass?
Q14
In Java, can a subclass override a private method from its superclass?
Q15
In Java, can a subclass override a protected method from its superclass?
Q16
Can a method be both overloaded and overridden in the same class in Java?
Q17
What is output of the program? class Test{ public void display(int x, double y){ System.out.println(x+y); } public double display(int p, double q){ return (p+q); } public static void main(String args[]){ Test test = new Test(); test.display(4, 5.0); System.out.println(test.display(4, 5.0)); } }
Q18
In method overloading, can methods have the same name and the same return type if their parameter types are different?
Q19
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) { Parent obj = new Parent(); obj.display(); } }
Q20
In Java, can a method be overloaded by changing only the return type?
Q21
What is the purpose of the "super" keyword in method overriding?
Q22
What is the difference between method overloading and method overriding in Java?
Q23
In method overloading, can methods have the same name and the same parameter types if their return types are different?
Q24
In method overriding, is it mandatory for the method name in the subclass to be the same as the method name in the superclass?
Q25
Which keyword is used to declare a method that cannot be overridden in Java?