Menu
Topics Index
...
`

Abdul Kalam


If you need explanation Read this topic

If you need Answer Take test on this topic

Abdul Kalam
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 = 0; 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 Character Extraction - toCharArray() Method In Java

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 A as abdul is not equal to kalam it results true as no of chars matches

Posted by Bharath Yelchuri    2014-05-22 12:50:21


output is A string name and abdul has same length it results true and prints

Posted by Naga Sinst    2014-05-22 13:12:24


No winner for this dose. Correct option is 'A' :(. Naga Sinst  was already won in this week.

Posted by Merit Campus    2014-05-23 04:49:06


© meritcampus 2019

All Rights Reserved.

Open In App