Menu
Topics Index
...
`

String Tokenizer


If you need explanation Read this topic

If you need Answer Take test on this topic

String Tokenizer
What will be the output of the following program?
import java.util.*;
    public class nextToken {
        public static void main(String[] args) {
        StringTokenizer st = new StringTokenizer("happydays, is,movie , .");
        System.out.println(st.nextToken(","));
    }
}

A. (EMPTY)
B. happydays
C. movie
D. Some other output
E. Compilation Error or 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.

Ans is B.. it will split the string using , as delimiter and returns the first token.

Posted by Krishna Sai    2014-07-24 04:59:57


B

Posted by Soham Dutta    2014-07-24 05:13:55


B st.nextToken(",") is delimiter, it wil split by ','.. so it will print only one token, unless used in while loop.

Posted by Arockia Raj    2014-07-24 05:26:46


B
delimiter (",")
.nextToken returns next token from tokenizer st
so it will return happydays

Posted by Tushar Ghude    2014-07-24 07:01:59


b

Posted by Zeg Abder    2014-07-24 08:37:06


happydays...........

Posted by Arul Palanisamy    2014-07-24 15:43:15


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

Posted by Merit Campus    2014-07-25 04:10:55


© meritcampus 2019

All Rights Reserved.

Open In App