712
System.out.println("The sum of "+ INT1 + " and "
+ INT2 + " is "+ (INT1+INT2));
System.out.println("Their product is "+ (INT1*INT2));
}
}
Chapter 4 Exam Preparation Exercises
1.A control structure changes the sequential execution of the statements in a
program.
2.A logical expression is an expression made up of logical values and operations.
The logical values may take the form of relational operators applied to numeric
values.
- a.xyxy
b.The value of x is 3
c. 376z
(Despite the indentation, the final output statement is not part of the else
clause.) - a. x < y && y <= z
b.x > 0 && y > 0 && z > 0
c. x != y && x != z
d.x == y && x == z
14.if(typeA || typeB)
{
if(typeA && typeB)
System.out.print("Type AB");
}
else
System.out.print("Type O");
Data Set ch1, ch2, ch3 Expected Output
Set 1 A, A, A All initials are the same.
Set 2 A, A, B First two are the same.
Set 3 B, A, A Last two are the same.
Set 4 A, B, A First and last are the same.
Set 5 A, B, C All initials are different.