Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

class test { public static void main(String [], args) { short a=10; int b=20; lo

ID: 3617286 • Letter: C

Question

class test { public static void main(String [], args) { short a=10; int b=20; long c=301L; b =(short) c; a=b; b=c; c=a; a=b; c=b; System.out.println(b); } } Question 1; Why are the erors being generated? Question 2; Will there be any data lost? Qusestion 3: Will there be any data loss if we used Maximum values of eachdata type. public static void main(String [], args) { short a=10; int b=20; long c=301L; b =(short) c; a=b; b=c; c=a; a=b; c=b; System.out.println(b); } } Question 1; Why are the erors being generated? Question 2; Will there be any data lost? Qusestion 3: Will there be any data loss if we used Maximum values of eachdata type.

Explanation / Answer

please rate - thanks Question 1; Why are the erors being generated? Question 1; Why are the erors being generated? class test { public static void main(String [], args){              //   , doesn't belong short a=10; int b=20; long c=301L; b =(short) c; a=b;                                                   //an int won't fit in a short b=c;                                                  //a long won't fit in an int c=a; a=b;                                                   //an int won't fit in a short c=b; System.out.println(b); } } Question 2; Will there be any data lost? if the program were to run no data would be lost. the largestvalue is 301 which will fit in a short Qusestion 3: Will there be any data loss if we used Maximum values of eachdata type. yes the int wouldn't fit in the short. the long won't fit in the int
public static void main(String [], args){              //   , doesn't belong short a=10; int b=20; long c=301L; b =(short) c; a=b;                                                   //an int won't fit in a short b=c;                                                  //a long won't fit in an int c=a; a=b;                                                   //an int won't fit in a short c=b; System.out.println(b); } } Question 2; Will there be any data lost? Question 2; Will there be any data lost? if the program were to run no data would be lost. the largestvalue is 301 which will fit in a short Qusestion 3: Will there be any data loss if we used Maximum values of eachdata type. yes the int wouldn't fit in the short. the long won't fit in the int