Re: my thread of basic Java questions
- From: "Arved Sandstrom" <asandstrom@xxxxxxxxxxxxx>
- Date: Sun, 13 Apr 2008 14:30:32 GMT
"Mark Space" <markspace@xxxxxxxxxxxxxx> wrote in message
news:NAhMj.5686$GE1.2828@xxxxxxxxxxxxxxxxxxxxxxx
denim_genes@xxxxxxxxxxx wrote:[ SNIP ]
On Apr 13, 12:18 am, Mark Space <marksp...@xxxxxxxxxxxxxx> wrote:
denim_ge...@xxxxxxxxxxx wrote:
Why is the following true?:It isn't true, and strings in Java have double quotes around them.
(ok || (n1 < 0))
And what the heck is "ok"?
My guess: any String or character or whatever is "true" on its own,
since it exists. Thus, "ok" could be replaced by "dinosaur", and the
answer to the question would still be true.
ok is obviously a variable that's been declared elsewhere, just like n1.
It's true... I'm looking at the answer key right now...
int dinosaur = 0;
dinosaur == true ?
It's false. I don't care about your answer key. Get a compiler and try
it, or better yet learn the language.
Your latest one here is wrong too, ints aren't even comparable to
booleans.:
This question brings up the always popular programming trivia contest...what
are the truth values in various programming languages? Not always easy to
remember...
For example, in awk "0" is true because it's a non-null string value.
However, in Perl "0" is false (but "0.0" is true). Apparently in REBOL the
integer 0 is true.
Does the language in question (1) use two boolean values, or (2) does it
define truth values for all values of datatypes, or (3) does it define two
boolean values *and* also truth values for values of other datatypes?
Example of #3 being Javascript.
Then there's the convention in UNIX that a program is considered to have
succeeded if it sets an exit code of 0, which can catch the novice shell
script programmer by surprise...
I think there was an attempt to design a bool class in C++ quite some back
but they couldn't quite design one that was completely correct, hence the
bool datatype. Of course you can still initialize a bool with 0...
AHS
.
- References:
- my thread of basic Java questions
- From: denim_genes
- Re: my thread of basic Java questions
- From: Mark Space
- Re: my thread of basic Java questions
- From: denim_genes
- Re: my thread of basic Java questions
- From: Mark Space
- my thread of basic Java questions
- Prev by Date: *** nike air max 91 shoes
- Next by Date: Re: my thread of basic Java questions
- Previous by thread: Re: my thread of basic Java questions
- Next by thread: Re: my thread of basic Java questions
- Index(es):