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?
Topic-wise practice questions for Programming (C++ / Java / Python). Test your knowledge, check solutions on demand, and pace your preparation.
int a = 127;
byte b = (byte) a;
b++;
print(b);
Assuming a standard 8-bit signed byte (-128 to 127):
double myValue = 9.99;
int result = (int) myValue;
print(result);