Computer Science, asked by khushboo6770, 1 year ago

4. void test 4(String x, String y)
if(x.compareTo(y) > 0)
System.out.println(x);
else
System.out.println(y);
if "AMIT" and "AMAN" are passed to the function.

Answers

Answered by siddhant123439
0

I can't understand what you are saying


khushboo6770: give the output of this program
Answered by sswaraj04
6

Answer:

OUTPUT:

AMIT

Explanation:

it compares lexicographically between two string

here it checks A==A true

M==M true

I==A false

it will return difference between value at smallest unequal index i.e 8 or simply (int)I-(int)A

8>0

print x i.e AMIT

IMPORTANT

***UNDERSTAND THE TERM LEXICOGRAPHICALY FROM SOMEWHERE***

Similar questions