Menu
Question Index
...

What will be the output of the following program?

public class JavaCourse {
    public static void main(String[] args) {
        String course = "Java is my Course";
        String school = "Merit Campus is my school";
        String start = "java";
        String end = "school";
        boolean starts1 = course.startsWith(start);
        boolean starts2 = school.endsWith(end);
        System.out.println(school + " - name ends with " + end + "? " + starts1);
        System.out.println(course + " - name starts with " + start + "? " + starts2);
    }
}


Merit Campus is my school - name ends with school? true
Java is my Course - name starts with java? true
Merit Campus is my school - name ends with school? false
Java is my Course - name starts with java? false
Merit Campus is my school - name ends with school? false
Java is my Course - name starts with java? true
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java String startsWith() And endsWith() Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App