Sail E0 Webinar
Question


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);
}
}
Options:
A .  true
B .  false
C .  0
D .  1
Answer: Option B

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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers