Explain the difference between an implicit type cast and an explicit type cast.

What will be an ideal response?


A type cast takes a value of one type and produces a value of another type. Java supports
two kinds of type casts: explicit and implicit. Java performs an implicit type cast automatically.
This can be seen in the declaration of a variable of type double that is assigned an integer value.
double castExample = 72;
The integer value assigned to the variable castExample is automatically converted to a floating point
number. The number assigned to castExample is converted to 72.0.
An explicit type cast occurs when the programmer explicitly forces a value of one type into a value
of another type. In the example that follows, the value 72.5 is explicitly cast into an integer value.
int castExample = (int) 72.5;

Computer Science & Information Technology

You might also like to view...

Which of the following is/are valid C++ identifiers?

A) June-2010 B) June.2010 C) June_2010 D) 2010June E) Both C and D.

Computer Science & Information Technology

C++ Standard Library function getline, from the header, reads characters up to, but not including, a(n)________ (which is discarded), then places the characters in a string.

a. tab b. period c. newline d. \

Computer Science & Information Technology

Which of the following is a Trojan horse that specifically affected computers running Mac OS X?

A) Net Bus B) Flash Back C) Brain Test D) Fin Fisher

Computer Science & Information Technology

Check boxes are selected by default.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology