Menu
Topics Index
...
`

String Test


If you need explanation Read this topic

If you need Answer Take test on this topic

String Test
What will be the output of the following program?
public class StringTest {
    public static void main(String[] args) {
        String String = "String";
        int temp = 2;
        Object : for (int main = 0; main < String.charAt(main); main++) {
            System.out.print(String.charAt(main) + "~");
            if (main > temp) {
                break Object;
            }
        }
    }
}

A. S~t~r~
B. S~t~r~i~
C. S~t~r~i~n~
D. S~t~r~i~n~g~
E. Compilation Error or Runtime Error
Topic: charAt() Method In Java - Java Character Extraction

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.

E

Posted by Manaswini Panuganti    2014-04-28 12:57:40


ANs is E.. since String is a keyword in java it cant be as a variable..

Posted by Om Prakash Om    2014-04-28 13:01:21


ans is B ,since char can be compared with integer,here for loop iterates four times,at fourth iteration main holds 3 and temp holds 2 so if conditon satisfies and breaks the block with label Object.

Posted by Raviteja Daggupati    2014-04-28 14:02:03


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

Posted by Merit Campus    2014-04-29 04:08:10


© meritcampus 2019

All Rights Reserved.

Open In App