Method Overloading and Method Overriding
Description: Method Overloading and Method Overriding | |
Number of Questions: 15 | |
Created by: Aliensbrain Bot | |
Tags: Method Overloading and Method Overriding Java/Oracle /C/C++ Java Basics of Java Computer Basics |
Which of the following statements is/are correct for static method in Java?
A. Static methods are always public. B. Static method cannot access directly non-static method of the same class.
Which of the following statement(s) is/are correct? A. valueOf() is a static method. B. toString() is overridden in Integer and Double Class.
Which of the following conditions is incorrect for performing overriding of methods in Java?
Which of the following statements is/are correct for recursion in Java? A. Recursion methods normally require extra memory. B. Recursion methods take more time.
What is the method used to convert String variable to primitive integer
What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?
Which method is not overridden by Annotation interface?
Which two statements are true about properly overridden hashCode() and equals() methods?
- hashCode() doesn't have to be overridden if equals() is.
- equals() doesn't have to be overridden if hashCode() is.
- hashCode() can always return the same value, regardless of the object that invoked it.
- equals() can be true even if it's comparing different objects.
What is the difference between constructor and other methods?
Which of the following statements are correct? i. final methods can be overridden ii. final fields are constants iii. final methods cannot be overridden iv. final variables can be changed
Which of the following statements is/are correct? :i. Overloaded methods are multiple methods which have the same name but different arguments. ii. Overridden methods are multiple methods which have the same name, same return type and same arguments. iii. Overloaded methods are multiple methods which have the same name, same return type and same arguments. iv. Overridden methods are multiple methods which have the same name but different arguments.
Which of the following is/are true regarding overriding methods? i. A method marked as final cannot be overridden. ii. A method marked as static can be overridden. iii. A method marked as final can be overridden. iv. A method marked as static cannot be overridden.
Which of the following are true regarding dynamic method dispatch? i. Dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile time. ii. Dynamic method dispatch is a process in which a call to an overridden method is resolved at compile time rather than at runtime. iii. In Dynamic method dispatch process, a reference variable calls the overridden method of a superclass. iv. In Dynamic method dispatch process, a reference variable calls the overridden method of a subclass.
Which of the following are true regarding super keyword? i. Any level can be accessed using super keyword. ii. In the constructor, if super() method is used, it should be the first code. iii. Super is the keyword which is used to access method or member variables from the superclass. iv. Super is the keyword which is used to access method or member variables from the subclass.
Which of the following is true regarding overriding main method? i. main method can be overridden because it is having access modifier as public. ii. main method can be overridden because it is having return type as void. iii. main method can be overridden because the method is static. iv. main method cannot be overridden.