Knowee
Questions
Features
Study Tools

What is the output of System.out.println('z' - 'a')? Group of answer choices2526az

Question

What is the output of System.out.println('z' - 'a')? Group of answer choices2526az

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of System.out.println('z' - 'a') in Java is 25.

Here's why:

In Java, char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive). When you subtract 'a' from 'z', you're actually subtracting their ASCII values.

The ASCII value of 'a' is 97 and 'z' is 122. So, when you subtract 'a' from 'z' (i.e., 122 - 97), you get 25.

So, System.out.println('z' - 'a') prints 25.

This problem has been solved

Similar Questions

the correct answerWhat will be the output of the following Java program? class mainclass { public static void main(String args[]) { char a = 'Z'; a++; System.out.print((int)a); } }Options9112290123

The statement System.out.printf("%.1f", 1234.56) outputs ________.Group of answer choices123.4123.51234.51234.6

What will the following print out?String shout = "hello";shout = shout.toUpperCase();System.out.println(shout);Group of answer choicesHELLO

What is the output upon execution of the following two lines of Java code?System.out.println("1 + 2 + 3");System.out.println(1 + 2 + 3);Group of answer choices66"6"61 + 2 + 31 + 2 + 31 + 2 + 36

What is the output of the following code snippet?int x = 5;int y = 2;int result = x % y;System.out.println(result);Question 2Answera.3b.2c.1d.0

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.