KnowledgeBoat Logo

Computer Applications

Consider the array given below:

char ch[] = {'A','E','I','O', 'U'};

Write the output of the following statements:

System.out.println(ch[0]*2);:
  1. 65
  2. 130
  3. 'A'
  4. 0

Java

Values & Data Types Java

ICSE Sp 2025

1 Like

Answer

130

Reason — The given array is:

char ch[] = {'A', 'E', 'I', 'O', 'U'};

Step-by-Step Execution:

1. ch[0]:

  • The element at index 0 of the array is 'A'.

2. Character Multiplication in Java:

  • In Java, a char is treated as a numeric value based on its ASCII code when used in arithmetic operations.
  • The ASCII value of 'A' is 65.

3. ch[0] * 2:

  • Substituting ch[0] with its ASCII value:
65 * 2 = 130

4. Output:

  • System.out.println(ch[0] * 2); will print 130.

Answered By

2 Likes


Related Questions