Menu
Question Index
...

What will be the output of the following program?

class Tokens
{
    public static void main(String[] args)
    {
        StringTokenizer st = new StringTokenizer("A~B#C~#D##E#~F~#G#H~ ~", "~#");
        while (st.hasMoreTokens())
        {
            if (st.nextToken().startsWith("A") || st.nextToken().startsWith("D"))
            {
                System.out.print(st.nextToken() + " ");
            }
        }
    }
}


A~B#C D##E#~F G#H~ ~
B E
A~B#C D##E#~F
A D
None of the above or it throws a run-time error

Doubts

Problems

Topic: StringTokenizer 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