‹ Back to the paper
Question 36
1 mark
Computer ScienceISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024)Case basedPrimitive values, Wrapper classes, Types and casting
Answer the following questions.
Ram and Hari are coder friends, who are debating effective usage of memory while using variables…
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)
long (a population count can exceed the range of int, so a larger integer type is used).
Answer (b)
float (a decimal value where double's extra precision is not needed, saving memory).