FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

WHAT IS PROGRAMMING

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
How many bytes are needed for an array of 1, 000 integers if each integer requires 32 bits of storage?
A
1, 000 bytes
B
4, 000 bytes
C
16, 000 bytes
D
32, 000 bytes
Explanation: 

Detailed explanation-1: -4-byte values (word, int) If we combine 4 bytes, we get a value with 32 bits, which can store 65536*65536 distinct values. This gives a range of approximately 4 billion different values. In many languages, a data type referred to simply as an “int” (=integer) is assumed to be 4 bytes.

Detailed explanation-2: -Each element of size = 2 bytes. So size of array is = 12 x 2 bytes =24 bytes. Hence the correct answer is 24 bytes. UPPCL Assistant Accountant Application Link is active on 8th November 2022!

Detailed explanation-3: -An Integer object has an overhead of about 24 byte (this is implementation specific) plus 4 byte for the data, so about 28 byte. An array is an object which also has an overhead of 24 bytes plus 4 bytes for the length plus data.

There is 1 question to complete.