Menu
Question Index
...

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);
        }
    }
}


Abdul Kalam true
Abdul Kalam false
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Character Extraction - toCharArray() Method In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App