Menu
Topics Index
...
`

Pet Name is


If you need explanation Read this topic

If you need Answer Take test on this topic

Pet Name is
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);
    }
}

A. Durga Bhavani
B. Durga  Bhavani
C. Bhavani
D. Durga
E. Compilation Error or Runtime Error
Topic: Java String substring() method - substring In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is A.
petname contains "Durga" and callname contains "Bhavani".
So it prints Durga Bhavani.

Posted by Gopinath Manchikanti    2014-09-05 12:47:15


ans is B ,,,

Posted by Raju VarshnEy    2014-09-05 13:09:29


Ans is A subString(8,14)
Contains durga  subString (14) contains bhavani it prints durga bhavani. SubString can have single parameters or double parameters that is begin index for single parameter double parameter contains begin and end index.

Posted by Ramya Reddy Addulla    2014-09-05 13:09:35


Ans is A.petname contains "Durga" and callname contains "Bhavani".So it prints Durga Bhavani.

Posted by Wajahat Khan    2014-09-05 13:26:02


Ans ==B

Posted by Pankaj Arora    2014-09-06 12:30:22


Congratulations Wajahat Khan. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-09-08 04:47:57


its A

Posted by Rohit Baranwal    2014-09-08 15:17:13


© meritcampus 2019

All Rights Reserved.

Open In App