Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is the syntax to cast a double to an int?
Remember to use parentheses for casting.
Explain what happens when casting from float to int.
Think about how rounding works.
What is the term for converting from a larger to a smaller data type in Java?
Think about how it affects the data size.
True or False: Explicit casting will always preserve the decimal portion of a float.
Remember what truncation means.
You have a variable double num = 150.75;. Write a Java snippet to safely define an int variable with this value while ensuring you document any potential issues.
What happens to the decimal part?
Given a float variable f with a value of 500.5, show what happens when you convert it to byte using explicit casting. Discuss the impact on the value.
Consider how overflow works in data types.
6 more questions in this section. Enroll free to practise them all.
Enroll free