Task 3 of 8 · 0 solved · 8 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

1.3 Types — a double prints with a decimal

Lesson

A double prints with a decimal point

A double value always prints with a fractional part, even a zero one: 5.0 prints as 5.0, not 5. If a variable is declared double, whole numbers stored in it also print with .0.


Worked example

int whole = 5;
double frac = 5.0;
System.out.println(whole);  // 5
System.out.println(frac);   // 5.0

▶ Try it: run this, then change something and run it again.



What does System.out.println(10.0); print?


What does this print?

double x = 4;
System.out.println(x);

Type exactly what this prints:

double y = 7;
System.out.println(y);

True or false?