Google
 
Site navigation: [ Home | Theory | Java | Moodle courses | Resource wiki | About ]

Selection quizzes

True/False and multiple choice.

You have a good chance of being right, right?

 

Try these, assuming:   char c = 'y'; int x = 5; int y = -5; int z = 2;

1. ((c == 'y') && (x == 5) || (z > y))
True
False

Does it matter whether z is greater or less than y?

2. (!(c == 'y') && (x == 5) || !(z > y))

True
False

Did you have to evaluate all parts of the expression this time?

3. !((c == 'y') && (x == 5) || (z > y))

True
False

Just checking, I'm sure you've got it by now... try something different:

4. (!(c == 'F') && !(y == 5) || (z-x > y))

True
False

OK Let's try our flip flp fly again:

int x = 9;
 int y = 0;
 int z = 3;
 char c = 'x';

 if (x == 9)
   if (y < 3)
     if (c != 'x')
       answer = "flip";
     else
       if (z >= 3)
         answer = "flop";
       else
         answer = "fly";

What's the value of answer?

flip
flop
fly

Related: [ Java Core | previous AddSub | next:Repetition ]

A few exercises for formative evaluation (testing yourself against the machine)


 
The site is partly financed by advertising revenue, partly by online teaching activities and partly by donations. If you or your organisation feel these resouces have been useful to you, please consider a donation, $9.95 is suggested. Please report any issues with the site, such as broken links, via the feedback page, thanks.

Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy.

Creative Commons License


This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand;
This page was last modified: May 31, 2009