Explain widening conversion and Narrowing conversion?
Submitted by: AdministratorFor a primitive data types, a value narrower data type can be converted to a value of a broader data type without loss of information. This is called Widening conversion. For example an int is directly converted to a double without first having to convert it to a long and a float.
Converting from a broader data type to a narrower data type is called narrowing conversion, which can result in loss of information. For example conversion between char and byte and short are narrowing conversions. For example byte takes 8 bits, short takes 16 bits, int takes 32 bits, long takes 64 bits. Conversion of short to int or int to long is widening conversion and conversion of int to short is a narrowing conversion.
Submitted by: Administrator
Converting from a broader data type to a narrower data type is called narrowing conversion, which can result in loss of information. For example conversion between char and byte and short are narrowing conversions. For example byte takes 8 bits, short takes 16 bits, int takes 32 bits, long takes 64 bits. Conversion of short to int or int to long is widening conversion and conversion of int to short is a narrowing conversion.
Submitted by: Administrator
Read Online Java Technical Job Interview Questions And Answers
Top Java Technical Questions
☺ | Explain Difference between Tomcat and Weblogic server? |
☺ | Explain different Authentication Options available in Servets? |
☺ | How does the native language C or C++ understand data types in JAVA? |
☺ | What is a StringBuffer class and how does it differ from String Class? |
☺ | read a line of input at a time in Java? |
Top Java Programming Language Categories
☺ | Core Java Interview Questions. |
☺ | Hibernate Interview Questions. |
☺ | Advanced Java Interview Questions. |
☺ | IBM WebSphere Interview Questions. |
☺ | Spring Framework Interview Questions. |