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[])
{
char ch;
ch = “hello”.charAt(1);
System.out.println(ch);
}
}

What will be the output of the following Java code?
class output
{
public static void main(String args[])
{
char ch;
ch = “hello”.charAt(1);
System.out.println(ch);
}
}
a) h
b) e
c) i
d) o

Answer: b
Explanation: “hello” is a String literal, method charAt() returns the character specified at the index position. Character at index position 1 is e of hello, hence ch contains e.
output:
e

Join The Discussion