+ 3
int x,y=5,z=5; x=y==z; System.out.println(x);
Please help me find out value of x ??
10 Respostas
+ 7
You will get compile time error.
x should be boolean type not int.
x= y==z
x= 5==5
x= true
+ 3
y==z, value of y is equal to value of z i.e. y=z=5;
Therefore,
y==z will return true i.e. 1
so, x will get;
x=1
+ 1
Thanks
+ 1
true
+ 1
Declare x as boolean
int y=5,z=5;
boolean x=y==z;
print(x);
0
if x is declare as bool x, then x will get value "true";
But x is declare as int variable.
So, x will get;
x=1
0
True
0
Error
0
Compilation error...
As x should be declared boolean instead of int ....
0
X=1