Menu
Topics Index
...
`

Abdul Kalam2129


If you need explanation Read this topic

If you need Answer Take test on this topic

Abdul Kalam2129
What will be the output of the following program?
public class AbdulKalam {
    public static void main(String[] args) {
        String name = "Abdul Kalam";
        String abdul = "", kalam = "";
        char charArray[] = name.toCharArray();
        for (int i = 0; i < name.length(); i++) {
            abdul += charArray[i];
        }
        for (int i = 1; i < charArray.length; i++) {
            kalam += name.charAt(i);
        }
        if (abdul.length() == kalam.length()) {
            System.out.print("Abdul Kalam " + true);
        } else {
            System.out.print("Abdul Kalam " + (abdul == kalam));
        }
    }
}

A. Abdul Kalam true
B. Abdul Kalam false
C. Some other output 
D. Compilation Error or Runtime Error 
Topic: Java equals method vs == Operator

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.

Ans is B.
because abdul = "Abdul Kalam" and kalam = "bdul Kalam"
becoz in 2nd for loop we are storing from index 1 of name.
It gives false.

Posted by Gopinath Manchikanti    2014-08-01 11:11:27


ans is b

Posted by Shubham Bansal    2014-08-01 17:29:04


b............

Posted by Arul Palanisamy    2014-08-02 04:08:44


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

Posted by Merit Campus    2014-08-04 06:03:15


© meritcampus 2019

All Rights Reserved.

Open In App