Java Classes and Objects
Java Classes and Objects - Important Points
6. | Which keyword is used to refer to the current object in Java? |
---|
A. this
B. super
C. final
D. abstract
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The this keyword is used to refer to the current object in Java.
7. | Which keyword is used to access the superclass in Java? |
---|
A. this
B. super
C. final
D. abstract
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The super keyword is used to access the superclass in Java.
8. | Which of the following is not a method in the Object class in Java? |
---|
A. toString()
B. hashCode()
C. equals()
D. clone()
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The clone() method is not a method in the Object class in Java.
9. | Which method is used to compare two objects for equality in Java? |
---|
A. toString()
B. hashCode()
C. equals()
D. compareTo()
View Answer Discuss Work SpaceAnswer: option c
Explanation:
The equals() method is used to compare two objects for equality in Java.
10. | Which of the following is true about static methods in Java? |
---|
A. They can access instance variables directly.
B. They can be overridden in a subclass.
C. They cannot access instance variables directly.
D. They can only be called from an object of the class.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
Static methods cannot access instance variables directly.