Which of the following expression are legal in Java 17 Which

Which of the following expression are legal in Java?
17. Which of the following expressions are legal in Java? If an expression is not legal, explain why. If it is legal, give its value. Assume x is an int variable with the value 5, y is a double variable with value 3.5, and b is a boolean variable with value false. A. (3 4 5) /3 4 5 2 6 D. 3 ++x. E. 0/0 F. y/x G. a b. H. a \"b \"c\" J. \"3\" (2 1) K. false true L. false true M. c\' 99 N. (3+4 5) & (4.6) I b (3 4) I (5 5) & (3

Solution

int x = 5;

double y = 3.5;

boolean b = false;

A.   (3+4/5)/3 = 1

B.    3*4%5/2*6 = 6

C.   3+ x++ = 8

D. 3+ ++x = 9

E. 0/0 ------Invalid

F. y/x = 0.7

G. \'a\' +\'b\' = 195(97+98(ascii values))

H. \'a\' + \'b\' +\"c\" = 195c

I. \"3\" +2+1 = 321

J. \"3\" +(2+1) = 33

K. false<true ---------Invalid

L. false = = true   ----------Invalid

M. \'c\' == 99 true

N. (3+4>5)&(4=6)|b -----------Invalid

O. !((3>4)|(5!=5))&(3<(4*0)) false

P.   !(3>4|5 != 5&3<4*0)-----------Invalid

19.

int x = 5;

x += 4;    // x= 9

x *= 2;   // x= 18            (9*2)

x /= 3; // x= 6              (18/3)

x %= 4;   // x= 2          (6%4=2)

Which of the following expression are legal in Java? 17. Which of the following expressions are legal in Java? If an expression is not legal, explain why. If it

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site