Menu
Question Index
...

What will be the output of the following program?

public class Speakers {
    public static void main(String args[]) {
        String str = "speakers";
        try {
            String str1 = str.substring(9);
            System.out.print(str1);
        } catch (StringIndexOutOfBoundsException e) {
            System.out.println("string index error");
        } finally {
            System.out.print("executed");
        }
    }
}


speakers
executed
string index error  
executed
speakers
string index error
executed
executed
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java String substring() method - substring In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App