How does compareto work in java?



How does compareto work in java?..

Answer / Kailash Chandra Singh

The `compareTo()` method is used by Comparable interface to compare two objects. It returns 0 if the objects are equal, a negative number if the current object comes before the passed object, and a positive number if it comes after.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is object data type?

1 Answers  


what is the default value of a variable char?(If not assigned)

4 Answers  


what are the oops concept in java explain with real time examples

24 Answers   Accenture, Bosch, Consummate Technologies, CTS, Current Technologies, iNautix, Infosys, Kekran Mekran, QA InfoTech, RTRT, SofTech, Tech Mahindra, Thorogood, Timios, Wipro,


What are user defined exceptions?

1 Answers  


whatis Home interface and Remoteinterface? with example?

1 Answers   Saksoft,


What do you understand by classes in java?

1 Answers  


Is 'null' a keyword?

8 Answers  


they asked class A{} class B{} class c{} all the three class saved as a single file,there is no main method in the file and anothe class M.java class m { psvm(String args[]) { // here the parent class can access } }

2 Answers   DNS, IPSR Solutions,


What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?

1 Answers  


Explain parallel processing in java8?

1 Answers  


What is polymorphism in java? What are the kinds of polymorphism?

1 Answers  


What are the procedures?

1 Answers  


Categories