Menu
Question Index
...

What will be the output of following program?

public class EnterNewName {
    public static void main(String[] args) {
        String kiran = "SEARCHING";
        String kirankumar = "READING";
        String kk = "SEARCHING";
        System.out.print(kiran.compareTo(kk) + ", ");
        System.out.print(kiran.compareTo(kirankumar) + ", ");
        System.out.print(kirankumar.compareTo(kiran));
    }
}


0, 1, -1
true, false, false
Some other output
Output can not be determined
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java compareTo() method

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App