Widening conversion and Narrowing conversion

Explain widening conversion and Narrowing conversion.

For 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.
How do we implement deep cloning?
Deep cloning makes a distinct copy of each of object’s field. By this the two objects are not dependent on each other...
Java features
Java features - Simple, Object-Oriented, Robust, Distributed, Portable, Interpreted, Multithreaded, Platform Independent, Secure...
Java program execution
Java program execution - What is JVM? Explain its roles and functions, Why Java is called as Platform independent language. How Java executable executes on any platform where JVM is available...
Post your comment