KnowledgeBoat Logo
|

Computer Applications

Consider the following array and answer the questions given below:

char ch [ ] = { ‘A’, ‘%’, ‘y’, ‘@’, ‘7’, ‘p’};

(a) How many bytes does the array occupy?

(b) What is the output of the statement Character.isDigit(ch[4])?

Java Arrays

3 Likes

Answer

(a) In Java, each element of type char occupies 2 bytes of memory. The given array has 6 elements, therefore:

Total memory = 6 × 2 = 12 bytes.

(b)

Output
true
Explanation
  • The element ch[4] contains the character '7'.
  • The method Character.isDigit('7') returns true because '7' is a numeric digit.

Answered By

1 Like


Related Questions