Logout

4.2.1 Define the Boolean operators and, or, not, nand, nor, and xor, by drawing the appropriate truth table. (No teaching notes for this one.)

Sample Question (in this case, sort of...)

The method logic1(), shown below, returns the output from a particular logic gate.
The logic gate has two inputs, a and b.

//parameters a and b can only have the values of 0 or 1
public boolean logic1(int a, int b){ 
    
    if(!(a==b)) return true;
else return false; }

(a) Identify the logic gate represented by the above method. [1 mark]
(b) Construct the method logic2(), which would similarly return the output from
a NAND gate. [2 marks]


JSR Notes:

The important thing to note with the assessment statement is that you are not to define as a dictionary would, rather you are to define the various Boolean operators by drawing the appropriate truth table.  Not that that’s not such a big deal; just do be prepared to do so.  I won’t bother with them all; they are done up properly in the textbook, though they are scattered over pages 231 to 235. But I think I should draw your attention to the two that were likely least gone over in class, but are as important as any of the rest: NOR and NAND. One point to make is that when drawing the truth table, you should include all four columns; both the and/or and the not and/not or.

 

A

 

B

 

table 1

 

table 2

0

0

0

1

0

1

0

1

1

0

0

1

1

1

1

0

 

 

 

 

 

 

 

 

 

 

A

 

B

 

table 3

 

table 4

0

0

0

1

0

1

1

0

1

0

1

0

1

1

1

0