Identify the interface which is used to declare core methods in Java?

Java MCQ: Identify the interface which is used to declare core methods in Java?

a) java.lang.Object
b) java.util.List
c) java.lang.Runnable
d) java.lang.Comparable

Answer:

d) java.lang.Comparable

Explanation:

The Comparable interface in Java is used to declare core methods for comparing objects. It defines the compareTo() method, which allows objects to be ordered. This interface is essential for sorting and comparing objects in collections.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top