cancel
Showing results for 
Search instead for 
Did you mean: 

binary comparison

Former Member
0 Kudos

Hello i m a beginner in java .kindly help me in solving this question.

wat 'll happen when u compile and run this code

int Output=10;

boolean b1=false;

if((b1==true)&& ((Output+=10)==20)){

System.out.println("We r equal" + Output);

} else {

System.out.println("not equal" + output);

}

Options---

1.Compile error, attempting to perform binary comparison on logical data type

2.Compilation and output of "We r equal 10"

3.Compilation and output of "Not equal 20"

4.Compilation and output of "Not equal 10"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

The Answer is

4.Compilation and output of "Not equal 10"

Because The else part will be executed insted of and condition the b1=false.

The + operator with the String always concatinate the String

and the variable

See this link

http://www.gginc.biz/jfront/index.html

Kind Regards

Mukesh

Former Member
0 Kudos

hi Payal,

The correct option is 4.Compilation and output of "Not equal 10"

Regards,

Richa

Answers (1)

Answers (1)

Torsten_
Advisor
Advisor
0 Kudos

Hello Payal,

I think it is not okay from you to let the forum guys answer all your exam question without approve by points.

Torsten