In the below different variable declaration is valid.
Class Test{
- int a=0.0;
- Integer b=23.4;
- String s='d';
- char c="sample";
- char ch[]="simple data";
- float f=34.5;
- double d=f;
- long l=d;
}
1.Compilation error. Error : Type mismatch: cannot convert from double to int
2.Compilation error: Error: Type mismatch: cannot convert from double to Integer
3.Compilation error: Error: Type mismatch: cannot convert from char to String
4.Compilation error: Error: Type mismatch: cannot convert from String to char
5.Compilation error: Error: Type mismatch: cannot convert from String to Char Array
6.Compilation error: Error: Type mismatch: cannot convert from double to float
8.Compilation error: Error: Type mismatch: cannot convert from double to long
No comments:
Post a Comment