Menu
Question Index
...

What will be the output of the following program?

public class Classifier {
    public static void main(String[] args) {
        System.out.print(type('Z') + type('\'') + type('6'));
    }
    public static String type(char c) {
        if ("0123456789".indexOf(c) >= 0)
            return "Number ";
        if ("abcdefghijklmnopqrstuvwxyz".indexOf(c) >= 0)
            return "Letter ";
        if ("\"'+-*/&|!=".indexOf(c) >= 0)
            return "Special-Character ";
        return "Incorrect ";
    }
}


Letter Special-Character Number
Letter Incorrect Number
Incorrect Special-Character Number
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Searching Strings - Java indexOf, lastIndexOf Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App