To test to see if a String called frank contains the same information as another String called desmond, you should use the following expression A) frank == desmond B) frank = desmond C) frank.equals(desmond) D) strcmp(frank, desmond) E) none of the above
In order to define a method as only being available to the class it is defined in you need to declare the method A) private B) public C) protected D) special E) none of the above
In order to specify a method while executing it as having come from the class itself, you need to prepend what to the method name: A) *this. B) that. C) myclass. D) super. E) none of the above
The system that handles freeing memory allocated by objects that are no longer in use is called the A) garbage collector B) free C) deleter D) vulcan neck pinch E) none of the above
Each loop structure must be controlled by a ____ value. A) integer B) double C) method D) boolean E) none of the above
When you have no end case, or the end case is impossible to reach in a loop you have a A) long execution B) rocking good time C) infinite loop D) segmentation fault E) none of the above
When you have a number keep track of how many times you have gone through a loop it is often called a A) loop invariant B) loop helper C) loop control value/variable D) floating point value E) none of the above
To declare a boolean value samseaborn and set it to true in one line, you might use a line that looks like A) bool samseaborn = true; B) boolean samseaborn = true; C) boolean samseaborn = true D) boolean samseaborn = true(); E) none of the above
When you execute a line of code or a block of code multiple times it is an example of A) repeating yourself B) doing a lot of nothing C) repetition D) recursive boolean values E) none of the above
Of the following, which is not a valid keyword used in loops in Java A) loop B) while C) do D) until E) none of the above
For the following questions write on your answer sheet T if the statement is true, f otherwise
You can define variables within your methods that are local variables
If you define a method of type private in a class you can directly execute it from a method that uses an object of the type of the class in question.
In order to avoid the condition of an infinite loop you should avoid having a loop control variables
In order to run code that needs to run only once, it makes sense to put them in a looping structure
For while loops it will check the condition before the execution of any loop.
Do while loops will execute at least once.
The following statements are based on the following section of code:
boolean b = false, a = false, c = false; // line 1
while (a && b) { // line 2
a = !a; // line 3
b = !a; // line 4
c = !c; // line 5
System.out.println(“Executing the code”); // line 6
}
The program will print executing the code exactly once.
If you change line 2 to replace && with || you will then execute the code forever
If you replace the while with a do until structure you will increase the number of executions of the loop
Line 5 is superfluous (doesn't do anything)
The sun ain't yellow, it's chicken!