MCQEasy1 mark
1
Choose the correct answers to the questions from the given options. (Do not copy the questions, write only the correct answers.)
int x = (int)32.8; is an example of __________ typecasting.
Topic: Type casting
Previous-year question practice database
Try it
Pick an option and check your answer. The full worked answer is below either way.
Answer
Exam answer
(c) explicit.
Explanation
Writing the type in brackets, as (int), is explicit type casting — the programmer forces the conversion. It is needed here because a double holds more than an int can, so Java will not do it silently; the value is truncated to 32, not rounded to 33. The opposite case, where a smaller type widens into a larger one automatically (int to double), is implicit casting, also called coercion.
In words
explicit.
More from Revision Tour I
The full form of JVM is:2026Which of the following occupies 2 bytes of storage?2026In a statement c = c + (x * d + e); which variable is an accumulator?2026Assertion (A): The result of the Java expression 3 + 7/2 is 6.
Reason (R): According to the hierarchy of operators in Java, addition is done first followed by division.2026Evaluate the Java expression:
x = a * b % (++c) + (++a) + (--b);
if a = 7, b = 8, c = 22026System.out.println('Z' + 32); will display:2025