Menu
Topics Index
...
`

Captains2224


If you need explanation Read this topic

If you need Answer Take test on this topic

Captains2224
What will be the output of the following program?
public class Captains {
    public static void main(String[] args) {
        String person = "Dhoni";
        String person1 = "Kapildev";
        boolean personResult = person.compareTo(person1);
        System.out.println(personResult);
    }
}

A. true
B. false
C. Compilation Error
D. Runtime Error
Topic: Java compareTo() method

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

C is the answer COMPILATION ERROR occurs..

Posted by Asad Ahmed    2014-01-22 13:26:54


answer is 'C' because compareTo method returns int value not boolean

Posted by Sai Teja    2014-01-22 13:40:52


Ans is C,Becz Incomptble types,compareTo returns int,bt v r takng into boolean

Posted by Uday Kumar    2014-01-22 13:51:14


Congratulations Sai Teja. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-01-23 04:11:47


© meritcampus 2019

All Rights Reserved.

Open In App