Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Java code?
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 will be the output of the following Java code?
class output
{
public static void main(String args[])
{
String c = “Hello i love java”;
boolean var;
var = c.startsWith(“hello”);
System.out.println(var);
}
}
a) True
b) false
c) 0
d) 1

Answer: b
Explanation: startsWith() method is case sensitive “hello” and “Hello” are treated differently, hence false is stored in var.
Output:
false

Join The Discussion