Question
class char_increment {
public static void main(String args[])
{
char c1 = 'D';
char c2 = 84;
c2++;
c1++;
System.out.println(c1 + " " + c2);
}
}
What is the output of this program?
class char_increment {
public static void main(String args[])
{
char c1 = 'D';
char c2 = 84;
c2++;
c1++;
System.out.println(c1 + " " + c2);
}
}
Answer: Option A
Was this answer helpful ?
Operator ++ increments the value of character by 1. c1 and c2 are given values D and 84, when
we use ++ operator their values increments by 1, c1 and c2 becomes E and U respectively.
output:
$ javac char_increment.java
$ java char_increment
E U
Was this answer helpful ?
More Questions on This Topic :
Question 1.
What is Truncation is Java?
....
Submit Solution