Determine the datatype of resultant variable.

Q5. Given that:

int x, m =2000;

short y;

byte b1 =-40, b2;

long n;

Which of the following assignment statements will evaluate correctly? Also determine the datatype of resultant variable.

  1. x=m*b1
  2. y=m*b1;
  3. n=m*3L
  4. x=m*3L;

Ans.

  1. x=m*b1 This expression will be evaluated correctly. The datatype of resultant variable will be int
  2. y=m*b1; This expression will generate error.
  3. n=m*3L; This expression will be evaluated correctly. The datatype of resultant variable will be long
  4. x=m*3L; This expression will generate error.

Leave a Reply

Your email address will not be published. Required fields are marked *

11 Views
%d bloggers like this: