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