Computer Applications
Arrange the following in the descending order of number of bytes occupied.
(i) char x[20]
(ii) int a[4][2]
(iii) double b[6]
- (iii), (ii), (i)
- (iii), (i), (ii)
- (ii), (iii), (i)
- (i), (ii), (iii)
Java Arrays
2 Likes
Answer
(iii), (i), (ii)
Reason — To find the number of bytes occupied by each array, we multiply the number of elements by the size of each data type:
(i) char x[20] — 20 elements * 2 bytes = 40 bytes
(ii) int a[4][2] — 4 * 2 = 8 elements * 4 bytes = 32 bytes
(iii) double b[6] — 6 elements * 8 bytes = 48 bytes
Now arranging in descending order: (iii) 48 bytes, (i) 40 bytes, (ii) 32 bytes
Answered By
2 Likes
Related Questions
Choose the statement which is equivalent to the given:
if(a>b) System.out.println("Honest"); else System.out.println("Sincere");a>b? System.out.println("Honest"):System.out.println("Sincere");System.out.println(a>b? "Honest":"Sincere");a>b? "Honest": "Sincere";a>b: "Honest"? "Sincere";
The two Java statement are used to check for the equality of the strings "COP" and "cop" are as follows:
"COP".equals("cop") "COP".equalsIgnoreCase("cop")The output of the above statements is:
- false, true
- true, false
- false, false
- true, true
The output of the java statement
"SOLDIER".compareTo("SOLUTE");is- -4
- -17
- 17
- 0
Sam performs bubble sort on the following array to organise the elements in ascending order:
{5, 1, 2, 3}After the first comparison the array is:
{1, 5, 2, 3}What would be the array after the next comparison?
- {1, 2, 5, 3}
- {1, 5, 3, 2}
- {1, 3, 5, 2}
- {1, 3, 2, 5}