PRASHNIKAप्रश्निका
‹ Back to the paper

Ram and Hari are coder friends, who are debating effective usage of memory while using variables…

Computer Science20251 markShort answer
Ram and Hari are coder friends, who are debating effective usage of memory while using variables, without compromising on precision of values. Help them on identifying the right data type to use, for the following data:
(a)[0.5]
Population of a country
(b)[0.5]
Interest rate in a bank account

Answer

Answer (a)

AI
long (a population count can exceed the range of int, so a larger integer type is used).

Answer (b)

AI
float (a decimal value where double's extra precision is not needed, saving memory).
Primitive values, Wrapper classes, Types and casting

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 36.