Term 1: Lesson 14 - Booleans and Truth Tables

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

nested conditionals

one if statement inside another, allows us to make one decision depending on another.

The ______ symbol takes the opposite of a boolean expression.

!

A || B

!(!A && !B)

order of boolean operations

!, &&, ||

!(A && B)

!A || !B

Assume that a, b and c have been defined and initialized as boolean values. The expression !(a && b) || (b && c) is equivalent to which of the following?

!a || !b || c

The ______ symbol shows an AND operation, where both sides of the command must be true for the entire command to be true.

&&

Assume that a and b have been declared and initialized with int values. Consider the following Java expression. (a % 10 = 0) && ((b % 5 = 0) || (a % 3 = 0)) Which of the following is equivalent to the expression given above?

((a % 10 = 0) && (b % 5 = 0)) || ((a % 10 = 0) && (a % 3 = 0))

Assume that x and y have been defined and initialized as int values. The expression !(!(x < y) || (y != 5)) is equivalent to which of the following?

(x < y) && (y = 5)

how are values of true or false stored?

1 and 0

Consider the following code segment, which uses the int value a. if ((a > 12) || (a < 4)) System.out.println("New value: " + a/3); else System.out.println("New value: " + 2*a); For which, if any, of the following initial values of a will the statement New value: 4 be printed when the code is executed?

13

&&

AND; Both must be true

Which is not a correct boolean condition? A. (x < y && 7 == 9) B. (y ! >= 9 || x == 9 ) C. (x == 9 || y != 9) D. (!(x > y) && y == 9)

B

When will the following Boolean conditions be true? int weight = scan.nextInt(); if (weight <= 10) if (weight > 3)

When weight is less than or equal to 10 and greater than 3.

!

NOT; Takes the opposite

||

OR; One or both must be true

true

The following truth table is the opposite of the && command.

A || ( A || B)

The following truth table matches which boolean condition?

The boolean data type handles true and false values.

True

boolean identities

finding pairs of statements which are equivalent

boolean data type

a variable that is either true or false

truth tables

a way of looking at all possible values of the variables, and determining the value of the whole statement, used to evaluate boolean statements

The data types int, double, and boolean allow us to use

all standard arithmetic operations (* / + -) and all boolean operators (! && ||) without ever requiring data types outside of these three

Assume that x and y are boolean values and have been properly initialized. (x || y) && !(x || y) The result of evaluating the expression above is best described by which of the following?

always false

Suppose that num has been declared as an int variable and initialized with a suitable value. Consider the following code segment. boolean answer = (num % 2 == 0); answer = !(answer && (num % 2 == 1)); Which of the following best describes the value of answer after this code segment has been executed?

always true

smallest of all the data types since it can only store two possible values (true and false)

boolean

the three primitive data types needed to know

boolean, int, and double

more complicated branching logical processes

can be made by by using multiple if and else statements inside others

Boolean operators

can be used to represent multiple conditions, combining boolean variables into more complex statements, which can still resolve to only true or false.

When two boolean statements always give the same true/false value as each other regardless of the circumstances we say the two statements are

equivalent

the word boolean comes from

the last name of a famous computer scientist, George Boole. Boole's contributions to mathematics and logic set the foundation for many modern day technologies. Without his work, computers would not be able to exist as they do today.

Assume that x and y have been declared and initialized with int values. Consider the following Java expression. (x < 10 && y > 7) || (x < 10 && y < 3) Which of the following is equivalent to the expression given above?

x < 10 && (y > 7 || y < 3)

Assume that x and y are variables of type int. The expression (x != y) && !(x > y) is equivalent to which of the following?

x < y


Set pelajaran terkait

Med Surg Ch 42 Coordinating Care for Patients with Adrenal Disorders

View Set

4.4 - Conversion, Obversion, and Contraposition

View Set

MANA3335 MindTap Assignment: Chapter 02: The Environments of Organizations and Managers

View Set