Menu
Question Index
...

What will be the output of the following program?

public class Merit {
    public static void main(String args[])
    {
        String str = "cba";
        String str1 = "abc";
        if (str.equals(str1)) {
            System.out.print("AAA");
        } else {
            System.out.print("BBB");
        }
        if (str1.equals(str)) {
            System.out.print("CCC");
        } else {
            System.out.print("DDD");
        }
    }
}


BBBDDD
AAACCC
AAADDD
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java String Comparison Methods - Equals and EqualsIgnoreCase

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App