Unit 5 - Selection and Iteration Flashcards
What is a modal dialogue?
A modal dialogue is one that will not allow you to interact with another part of the program or system until you have responded to it by clicking one of the buttons presented.
What is an instance method?
instance methods are called this because of their relationship with instances of a class (that is, objects).
What are static methods?
Also referred to as class methods, they are called this because of how they look in the editor.
static void alert (String prompt)
Write down a statement that when executed displays a dialogue box which say “hey! click this!!” and and “OK” button
nothing else!
OUDialog.alert(“hey! click this!!”);
how is each of the following lines in the sequence executed?
String name;
name = “Patrick”;
name = name.toUpperCase();
OUDialog.alert(“The name was “ + name);
Line 1 declares a variable of type String whose identifier is name. Line 2 makes the variable name reference the String object "Patrick". Line 3 makes the varaible name reference the new String object returned when the object "Patrick" referenced by name is sent the message toUpperCase(). Line 4 uses the method alert() of the OUDialog class with the argument resulting from concatenating "The name was " with the object referenced by name, which, from line 3 is now "PATRICK".
What is the scope?
It is the the region within which a variable can be accessed, for example a local variable can only be accessed from inside the method with whcih it is associated.
How do I convert an integer to its string value?
String.valueOf(100);
for example
how do i convert a string representation of a integer to its integer value?
Integer.parseInt(“1905”);
for example
What is a statement block?
In an IF statement, the braces { and } and any code between them are called a statement block or just a block
What is lazy or short-circuit evaluation?
When using the Boolean operand AND - A and B is False as soon as A evaluates to False, therefore the program does not need to evaluate B as it could never make the whole expression A and B true.
This is lazy.
in for loops what is the loop control variable?
this is in the initialise section of the for loop’s operation control structure, it is the declared variable.
What are the roles of the three sections within a for loops operation control structure?
The initialise section typically declares and initialises a variable, which we calle the loop control variable.
The condiiton section contains a Boolean expression; that is, something that can be evaluated to true or false. it is also called the termination condition, since when it evaluates to false, the loop terminates.
The update section normally updates the variable declared in the initialisation section; typically it increments or decrements the loop control variable.