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