Widening and Narrowing in Java

By | August 8, 2020

Widening and Narrowing in Java:

In this article, you are going to learn what is widening and narrowing in Java.

Widening:

Widening is also known as Upcasting. Widening casting is automatic. It happens when we pass a variable of smaller size data type to larger data type. Widening takes place when a reference variable of a subclass is automatically accommodated in the reference variable of its super class.

Widening conversions permitted in Java:

 

Narrowing:

Type conversion that happens when a variable of large size assigned to a variable of smaller size. Narrowing is usually done through explicit cast.

Narrowing conversions allowed in Java:

 

Recommended Posts:

How to remove last element from an ArrayList

Remove element from ArrayList

How to swap two numbers without using third variable in Java ***

How to capitalize each word in Java

Java interview questions

Generate random between 1 to 10 in Java

 

Note: If you like selenium99.com and want to contribute any articles, then please send your articles to techygeeks99@gmail.com. 

If you want to improve this article or find any mistake in the article, then please use comment box to share your feedback.

Links: TestNG

Tags: widening and narrowing in java

Leave a Reply

Your email address will not be published. Required fields are marked *