Tuesday, January 5, 2021

 Type Casting:

The process of converting value of one Datatype to another Datatype. Two ways of Casting:

Widening:  Converting a smaller datatype to higher datatype is called widening.

byte-> short -> char -> int -> long -> float -> double

widening happens automatically and it is safe operation. We also call widening as implicit casting.

              Ex:       int n=10;

                          float  x=n;

Narrowing: Converting a higher datatype to smaller datatype is called narrowing.

double -> float -> long -> int -> char -> short -> byte

narrowing happens manually and it is not safe operation. We also call narrowing as explicit casting.

              Ex:       float     n=10.2f;

                          int x=(int)n                  Output: 10

 

0 comments:

Post a Comment

selenium-repo by venu

Blog helps to a student or IT employee to develop or improve skills in Software Testing.
For Online Classes Email us: gadiparthi122@mail.com

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts