Menu
Question Index
...

What will be the output of the following program?

public class Seasons {

    public static void main(String[] args) {
        String s = "summerautumnwinterspring";
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < 6; j++, i++) {
                System.out.print(j == 0 ? Character.toUpperCase(s.charAt(i)) : s.charAt(i));
            }
            System.out.print(" ");
        }
    }
}


Summer Autumn Winter Spring
SUMMER AUTUMN WINTER SPRING
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Character Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App