Question 33
Is the assignment operator a unary operator or a binary operator. Select one or the other.
Question 34
True or false? In Java, when using the assignment operator, the value stored in memory and represented by the right operand is copied into the memoryrepresented by the left operand. If your answer is False, explain why.
Question 35
Show two of the shortcut assignment operators and explain how they behave by comparing them with the regular (non-shortcut) versions. Hint: the (^=) operator is a shortcut assignment operator.
Question 36
Write a Java application that clearly illustrates the difference betweenthe prefix and the postfix versions of the increment operator. Provide a termination message that displays your name.
Question 37
Write a Java application that illustrates the use of the followingrelational operators:
<><=>=
==!=
Provide appropriate text in the output. Also provide a termination message with your name.
Question 38
write a Java application that illustrates the use of the followinglogical or conditional operators:
&&||!
Provide appropriate text in the output. Also provide a termination message with your name.
Listings
- Listing 1 . Listing for Question 13.
- Listing 2 . Listing for Question 22.
- Listing 3 . Listing for Answer 38.
- Listing 4 . Listing for Answer 37.
- Listing 5 . Listing for Answer 36.
What is the meaning of the following two images?
This image was inserted here simply to insert some space between the questions and the answers to keep them from being visible on the screen at thesame time.
The image is also an example of the kinds of things that we do in my course titled ITSE 2321, Object-Oriented Programming.
This image was also inserted for the purpose of inserting space between the questions and the answers.
Answers
Answer 38
Listing 3 . Listing for Answer 38. |
---|
/*File SampProg09.java from module 22
Copyright 1997, R.G.BaldwinWithout reviewing the following solution, write a Java
application that illustrates the use of the followinglogical or conditional operators:&&|| !
Provide appropriate text in the output. Also providea termination message with your name.
*********************************************************/class SampProg09 { //define the controlling class
public static void main(String[]args){ //define main
System.out.println("true and true is "+ (true&&true) );
System.out.println("true and false is "+ (true&&false) );
System.out.println("true or true is "+ (true || true) );
System.out.println("true or false is "+ (true || false) );
System.out.println("false or false is "+ (false || false) );System.out.println("not true is " + (! true) );
System.out.println("not false is " + (! false) );System.out.println("Terminating, Dick Baldwin");
}//end main}//End SampProg09 class. Note no semicolon required |
Answer 37
Listing 4 . Listing for Answer 37. |
---|
/*File SampProg08.java from module 22
Copyright 1997, R.G.BaldwinWithout reviewing the following solution, write a Java
application that illustrates the use of the followingrelational operators:<><=>= == !=
Provide appropriate text in the output. Also providea termination message with your name.
*********************************************************/class SampProg08 { //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 ) );
System.out.println("The relational 5>=5 is "
+ (5>=5 ) );
System.out.println("The relational 5<=5 is "
+ (5<=5 ) );
System.out.println("The relational 6==5 is "+ (6==5 ) );
System.out.println("The relational 6!=5 is "+ (6!=5 ) );
System.out.println("Terminating, Dick Baldwin");}//end main
}//End SampProg08 class. Note no semicolon required |