Question
class output {
public static void main(String args[])
{
String c = "Hello i love java";
boolean var;
var = c.startsWith("hello");
System.out.println(var);
}
}
What is the output of this program?
class output {
public static void main(String args[])
{
String c = "Hello i love java";
boolean var;
var = c.startsWith("hello");
System.out.println(var);
}
}
Answer: Option B
Was this answer helpful ?
startsWith() method is case sensitive "hello" and "Hello" are treated differently, hence false
is stored in var.
Output:
$ javac output.java
$ java output
false
Was this answer helpful ?
More Questions on This Topic :
Question 1.
Which of these is an oncorrect statement?
....
Submit Solution