Menu
Question Index
...

What will be the output of following program?

public class PetName {
    public static void main(String args[]) {
        String Myname = "Venkata Durga Bhavani";
        String petname = "";
        petname = Myname.substring(8, (Myname.length() - 7));
        String callname = Myname.substring(14);
        System.out.print(petname + "" + callname);
    }
}


Durga Bhavani
Durga  Bhavani
Bhavani
Durga
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