मराठी

Explain the following: Type Conversion and its forms

Advertisements

प्रश्न

Explain the following:

Type Conversion and its forms

स्पष्ट करा
Advertisements

उत्तर

Type Conversion in Java is the process of converting a value from one data type into another data type. It is used when a value of one data type needs to be assigned to a variable of another data type.

1. Implicit Type Conversion (Automatic Conversion):

Implicit type conversion is the process in which Java automatically converts a smaller compatible data type into a larger data type without any loss of information.

Example:

int a = 10;
double b = a;

2. Explicit Type Conversion (Type Casting):

Explicit type conversion is the process in which the programmer manually converts a value from one data type into another using the casting operator. It may result in loss of data.

Example:

double a = 10.75;
int b = (int) a;
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३२]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 6 Variables and Expressions
EXERCISE | Q 34. (b) | पृष्ठ १३२
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×