Question
class output {
public static void main(String args[])
{
String s1 = "Hello World";
String s2 = s1.substring(0 , 4);
System.out.println(s2);
}
}
What is the output of this program?
class output {
public static void main(String args[])
{
String s1 = "Hello World";
String s2 = s1.substring(0 , 4);
System.out.println(s2);
}
}
Answer: Option A
Was this answer helpful ?
substring(0,4) returns the character from 0 th position to 3 rd position.
output:
$ javac output.java
$ java output
Hell
Was this answer helpful ?
More Questions on This Topic :
Question 8.
Which of these is an oncorrect statement?
....
Question 10.
Which of the following statement is correct?
....
Submit Solution