Menu
Topics Index
...
`

Strings1953


If you need explanation Read this topic

Strings1953
What will be the output of the following program?
public class StartsAndEnd {
    public static void main(String a[]) {
        String str = "There are many students with great application skills, we want to identify them and show them themselves and their capabilities.";
        System.out.print(str.startsWith("The") + ", ");
        System.out.print(str.endsWith("capabilities.") + ", ");
        System.out.print(str.endsWith("lities.") + ", ");
        System.out.print(str.startsWith("plication", 37) + ", ");
        System.out.println(str.subSequence(15, 24));
    }
}

A. true, true, true, true, students with great appl
B. true, true, true, false, students
C. true, true, true, true, students
D. Some other output
E. Compilation Error  or Runtime Error
Topic: Java Comparable Interface with Example

If you need explanation Read this topic

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

Ans is C.. str starting with The, and ends with capabilities., plication istring starting from 37 index. so true, 15,24 chars are students..

Posted by Nanda Kishore    2013-11-22 09:06:02


ans is C...startsWith checks at the begining of string unless position is specified...endsWith matches the sufix...so all return true...substring within given positions is students

Posted by Santosh Munugota    2013-11-22 10:44:10


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

Posted by Merit Campus    2013-11-25 03:33:53


© meritcampus 2019

All Rights Reserved.

Open In App