Question 18
When the plus operator (+) is used as a concatenation operator, what is the nature of its behavior if its left operand is of type String and its right operand is not of type String ? If the right operand is a variable that is not of type String , what is the impact of this behavior on that variable.
Question 19
Show and describe four unary arithmetic operators supported by Java.
Question 20
What is the type returned by relational operators in Java?
Question 21
Show and describe six different relational operators supported byJava.
Question 22
Show the output that would be produced by the Java application shown in Listing 2 .
Listing 2 . Listing for Question 22. |
---|
class relat01 { //define the controlling class
public static void main(String[]args){ //define main
System.out.println("The relational 6<5 is " + (6<5 ));
System.out.println("The relational 6>5 is " + (6>5 ));
}//end main}//End relat01 class. Note no semicolon required
//End Java application |
Question 23
Show and describe three operators (frequently referred to as conditional or logical operators) that are often combined with relational operators to construct more complex expressions (often called conditional expressions) . Hint: The || operator returns true if either the left operand, the right operand, or both operands are true. What are the other two and how do theybehave?
Question 24
Describe the special behavior of the || operator in the following expression for the case where the value of the variable a is less than the value of the variable b .
(a<b) || (c<d)
Question 25
Show the symbols used for the bitwise and operator and the bitwise inclusive or operator.
Question 26
Show and describe seven operators in Java that perform actions on the operands one bit at a time (bitwise operators) .
Question 27
True or false? In Java, the signed right shift operation populates the vacated bits with the zeros, while the left shift and the unsigned right shift populate the vacated bits with the sign bit. If your answer is False,explain why.
Question 28
True or false? In a signed right-shift operation in Java, the bits shifted off the right end are lost. If your answer is False, explain why.
Question 29
Using the symbols 1 and 0, construct a truth table showing the four possible combinations of 1 and 0. Using a 1 or a 0, show the result of the bitwise and operation on these four combinations of 1 and 0.
Question 30
Using the symbols 1 and 0 construct a truth table showing the four possible combinations of 1 and 0. Using a 1 or a 0, show the result of the bitwise inclusive or operation on these four combinations of 1 and 0.
Question 31
Using the symbols 1 and 0 construct a truth table showing the four possible combinations of 1 and 0. Using a 1 or a 0, show the result of the bitwise exclusive or operation on these four combinations of 1 and 0.
Question 32
True or false? For the exclusive or , if the two bits are different, the result is a 1. If the two bits are the same, the result is a 0. If youranswer is False, explain why.