Menu
Topics Index
...
`

StringTokenizer2897


If you need explanation Read this topic

If you need Answer Take test on this topic

StringTokenizer2897
What will be the output of the following program?
import java.util.*;
public class Chess {
    public static void main(String[] args) {
        String team = "Pawn Elephant Knight Bishop King Minister";
        StringTokenizer enemy = new StringTokenizer(team);
        while (!enemy.nextToken().isEmpty()) {
            System.out.print(enemy.nextToken() + " ");
        }
    }
}

A. Pawn Elephant Knight Bishop King Minister
B. Elephant Bishop Minister
C. Compilation Error
D. Runtime Error
Topic: StringTokenizer 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.

c.no such elemnt exception in nextT0ken()...

NoSuchElementException--This is thrown if there are no more tokens in this tokenizer's string.

Posted by Wajahat Khan    2014-08-26 04:17:42


Ans is D...exception wil raised after printing elephant,bishop minster

Posted by Uday Kumar    2014-08-26 04:27:39


d.no such element exception.as dere is no more tokwns in srrng tokenozr....nothng will b printed

Posted by Asma Mujtaba Khan    2014-08-26 04:38:47


Sayyed Saulat Mubeen .??

Posted by Nasir Khan    2014-08-26 05:48:29


d

Posted by Rayapudi Ramya    2014-08-26 14:27:14


D

Posted by Raju VarshnEy    2014-08-26 14:44:16


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

Posted by Merit Campus    2014-08-27 04:45:53


© meritcampus 2019

All Rights Reserved.

Open In App