wood burning stoves*
The moose likes Beginning Java and the fly likes boolean quiz Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "boolean quiz" Watch "boolean quiz" New topic
Author

boolean quiz

Ade Fapetu
Greenhorn

Joined: Oct 09, 2005
Posts: 6
write an expression that evaluates to true if and only if the value of the integer variable x is equal to zero
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

OK, tell us your answer, and we'll tell you if it's right.


[Jess in Action][AskingGoodQuestions]
Ade Fapetu
Greenhorn

Joined: Oct 09, 2005
Posts: 6
x<=0 is 1
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

The question asks for an expression that is true if x is equal to 0. "==" means "is equal to" in Java. Want to try again?
Ade Fapetu
Greenhorn

Joined: Oct 09, 2005
Posts: 6
(x == 0)is true
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, I think you've got it; I'm not sure if the "is true" is part of your answer or not. The correct answer is "x == 0"; you'd use such an expression in code like

Ade Fapetu
Greenhorn

Joined: Oct 09, 2005
Posts: 6
Thanks! I have tried this before, but it was giving me that 'there is no need for an If statement in this exercise. it says write an expression only. says no semicolons either. will you be able to stil help?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18971
    
  40

If "it" doesn't like the "if" statement, then don't use it. The "if" keyword was not part of the expression anyway.



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: boolean quiz