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

 

Related Posts:

  • Palindrome Number Program in Java Palindrome Number: A Palindrome number is a number that remains the same when its digits are reversed. We get total 90 numbers between 100 and 1000. public class PalindromeNumber { public static void main(String[] a… Read More
  • 2nd highest salary of an employee? MySQL: Sub queries in SQL are great tool for this kind of scenario, here we first select maximum salary and then another maximum excluding result of subquery mysql> SELECT max(salary) FROM Employee WHERE salary NOT IN (S… Read More
  • Explain public static void main(String[] args){} public static void main(String[] args){} or public static void main(String... args){}: Java main method is the entry point of any java program. Its syntax is always "public static void main(String[] args)". You can only… Read More
  • pom.xml in Maven A Project Object Model or POM is the fundamental unit of work in Maven. It contains the project configuration details used by Maven. Some of the configuration that can be specified in the POM are the project dependencies, th… Read More
  • Fibonacci Series Write a Java Program to print Fibonacci  series up to 10        public class Fibonacci { public static void main(String[] args) { int num = 10;  … Read More

0 comments:

Post a Comment

Selenium Training in Realtime

Blog helps to a student or IT employee to develop or improve skills in Software Testing.

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