Menu
Question Index
...

What will be output of the following program?

import java.util.*;

public class ScannerExample {
    public static void main(String arg[]) {
        String str = "Indians are the champions";
        Scanner sc = new Scanner(str);
        str = sc.next();
        System.out.println(str);
        str += sc.next();
        System.out.println(str);
        str += sc.next();
        System.out.println(str);
    }
}


Indians
Indians are
Indians are the
Indians
Indiansare
Indiansarethe
Indians are the champions
Indians are the championsIndians are the champions
Indians are the championsIndians are the championsIndians are the champions
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Scanner Class Constructors With Example

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App