"Hi, Amigo. Here are some tasks involving integer type conversion. Add cast operators where necessary:"
12
Task
New Java Syntax,
level 12,
lesson 4
Locked
From a small bucket to a big one
When two long numbers are multiplied, the result may exceed the capacity of the long type.
If precision is not important, then one option could be to store the result as a floating point number.
Implement the getSquare method. It should return the square of the input argument.
12
Task
New Java Syntax,
level 12,
lesson 4
Locked
Approximate value
When converting from integers to floating point numbers, the lower order parts of numbers may be discarded. Let's test this in practice.
In the getDifference method, the incoming argument has already been converted to a float.
Determine what was discarded during the conversion and return the missing
12
Task
New Java Syntax,
level 12,
lesson 4
Locked
Conscious choice
When a type is narrowed, part of a number might be discarded. Or it might not.
Implement the isByte, isShort, and isInt methods. They should determine whether the input argument can be respectively converted to the byte, short, and int types "without serious consequences".
12
Task
New Java Syntax,
level 12,
lesson 4
Locked
Task No. 1 about integer type conversions
This task begins a series of tasks about integer type conversions. This is not a very difficult topic, but it often bewilders noobies because instructors sometimes put in at the very beginning, which is fundamentally wrong. But on Level 10, you're ready. Arrange the cast operators correctly to get the required result: d > 0. The operators are in the conditions.
12
Task
New Java Syntax,
level 12,
lesson 4
Locked
Task No. 3 about integer type conversions
"Nothing organizes your thinking as much as performing integer type conversions in your head. Of course, a compiler will also suffice". And now, the third task in the "Integer Type Conversion" series. We have some variables converted to another type, but we don't have enough of them. We need to add one type cast operation to obtain the require answer.
12
Task
New Java Syntax,
level 12,
lesson 4
Locked
Task No. 6 about integer type conversions
Here's the sixth task in the "Integer Type Conversions" series. What are we shooting for here? We want you to master these techniques so you don't have to relearn them. This time our task has too many cast operators. Superfluous conversions have crept in. Find and remove them to get the required answer.
GO TO FULL VERSION