Data Types & Variables MCQs

Topic-wise practice questions for Programming (C++ / Java / Python). Test your knowledge, check solutions on demand, and pace your preparation.

Zero-leak answer engine • Rate-limited explanations
Practice in Timed Mode
Q1medium
An application needs to represent four specific states of an order: PENDING, SHIPPED, DELIVERED, CANCELLED. What is the most type-safe way to represent this?
Q2medium
Trace this logic:

int a = 127;
byte b = (byte) a;
b++;
print(b);
Assuming a standard 8-bit signed byte (-128 to 127):
Q3medium
You are calculating the interest on a bank account with 10 million users. Using float for the balance results in a discrepancy of $50,000 across the whole system. What is the cause?
Q4easy
What is the output of the following C++/Java code?

double myValue = 9.99;
int result = (int) myValue;
print(result);
Q5medium
In memory management, where are Primitive variables usually stored compared to Reference objects?
Q6medium
You are designing a system to store the population of the world (approx. 8 billion). Which data type is the most appropriate to prevent overflow?
Q7medium
A developer writes: float price = 19.99; in Java/C#. The compiler throws an error: "Incompatible types: possible lossy conversion from double to float." Why?
Q8easy
What is the difference between const and readonly in C#?
Q9easy
Why are String objects "Immutable" in languages like Java and Python?
Q10easy
Which of the following is an example of an "Unsigned" data type violation?