Flashcards

Quick study sessions to strengthen memory and retain key concepts.

Flashcard Study

Java: Numeric Types and Money Basics

Front

When to use double in e-commerce?

Use double for non-critical precision. Frame the concept in practical terms so you can explain it during interview…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

How to handle rounding with BigDecimal?

Use setScale() for rounding. Frame the concept in practical terms so you can explain it during interview discussion.…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

Why might double cause issues in pricing?

double may introduce rounding errors. Frame the concept in practical terms so you can explain it during interview…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

Common mistake when converting double to BigDecimal?

Avoid using BigDecimal(double) constructor. Using `BigDecimal(double)` can introduce precision errors. Instead, convert to String first: `BigDecimal value =…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

How to add two BigDecimal values?

Use the add() method for BigDecimal. Frame the concept in practical terms so you can explain it during…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

What happens with int division in Java?

Integer division truncates the decimal. Frame the concept in practical terms so you can explain it during interview…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

Why is BigDecimal preferred for currency?

BigDecimal offers precise control over decimal numbers. For e-commerce, where cents matter, BigDecimal prevents rounding errors. Use it…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

How would you explain a double in a Java interview?

double is a data type for decimal numbers. double is used to store decimal numbers and provides more…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

Why choose int for storing product quantities?

int is ideal for whole numbers like quantities. In an e-commerce scenario, product quantities are whole numbers. For…

View Card →
Flashcard Study

Java: Numeric Types and Money Basics

Front

Why do Java developers often use `BigDecimal` for money?

Because it handles decimal arithmetic more explicitly than floating-point types. Money calculations are sensitive to rounding and precision.…

View Card →