← Quiz: Java Data Types: all 10 questions
Quiz: Java Data Types · Question 4 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
char c = 'a';
System.out.println(c + 1);
}
}
- A.b
- B.98
- C.a1
- D.Error
Answer & explanation
Correct answer: 98
char + int gives an int: 'a' is 97, so 97 + 1 = 98. Cast to char to get 'b'.
Can you get the rest right without peeking?
Take the timed Quiz: Java Data Types quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →