Computer Science, asked by saikrishsja, 3 months ago

Write the output for the following:
String s1 = ''Life is Beautiful'';
System.out.println (''Earth'' + s1.substring(4));
System.out.println( s1.endsWith(''L'') );

Answers

Answered by dreamrob
2

Given:

String s1 = ''Life is Beautiful'';

System.out.println (''Earth'' + s1.substring(4));

System.out.println( s1.endsWith(''L'') );

Output:

Earth is Beautiful

false

Explanation:

s1.substring(4) : This will extract the string from index 4 till the last index

4th index is blank space. So string from "  is Beautiful" will be extracted.

So, the output is Earth is Beautiful.

s1.endsWith(''L'') : endsWith() is case sensitive.

So, 'l' is not equal to 'L'

Therefore, output is false.

Similar questions