Java provides two kinds of data type conversions, namely automatic and explicit. Automatic conversion takes place when the following two conditions are fulfilled:
- The two types are compatible.
- The destination type is larger than the source type.
When these two conditions are met, widening conversion takes place, i.e., a narrow data type is promoted to a wider one. For example, the value of byte type will be promoted to int, as int is wider than byte in width. However, in many cases, an automatic conversion cannot be performed. For example, an automatic conversion cannot be performed to convert int to byte, as int is wider than byte. In such cases, conversion is performed explicitly. The general form to perform such type of narrowing conversion is as follows:
- Download free practice test for CIW Master CIW Enterprise Developer exam.
- Click here to get free scbcd SCBCD exam practice questions.
- Click here to download scdjws test study guide and practice question.
- Download free practice test for scjp SCJP exam.
- Download practice question and study guide for scjp-5-0 for exam.
- Download free practice test for SUN SCMAD exam.
- Download free practice test for scwcd SCWCD exam.
- Download practice question and study guide for CX310-055 for exam.
- Click here to get free CX310-065 SCJP 6.0 exam practice questions.
If you like this article, please leave a comment or subscribe this blog via RSS or via e-mail, Bookmark and share through your network. Click the AddThis button below. Thanks.