- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Conversions and Promotions
We can convert one data types into another data type using casting.
Narrowing Conversion
Narrowing refers to passing a higher size data type like int to a lower size data type like short. It may lead to data loss. Following program output will be 44.
public class MyFirstJavaProgram { public static void main(String []args) { int a = 300; byte b = (byte)a; // narrowing System.out.println(b); } }
Widening/Promotion Conversion
Widening refers to passing a lower size data type like int to a higher size data type like long.
public class MyFirstJavaProgram { public static void main(String []args) { int a = 300; long b = a; System.out.println(b); } }
- Related Articles
- Integer Promotions in C
- What are implicit and explicit type conversions in C language?
- What are implicit type conversions in C#?
- What are explicit type conversions in C#?
- Conversions between color systems using Python (colorsys)
- Write a C program for time conversions using if and elseif statements
- Different ways for Integer to String Conversions in C#
- Explain the conversions of expressions of stacks in C language
- Make the following conversions A. 140 degree Fahrenheit into degree celsius B. 303 k into degree Celsius
- How would you bring about the following conversions? Name the process and write the reaction involved.(a) ethanol to ethene.(b) propanol to propanoic acid. Write the reactions.
- Difference between Java SE, Java EE, and Java ME?
- Differences between Java 8 and Java 9?
- Java overflow and underflow
- Java Boxing and Widening
- Java AND Operator Examples

Advertisements