Unit 5 - Selection and Iteration Flashcards

1
Q

What is a modal dialogue?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an instance method?

A

instance methods are called this because of their relationship with instances of a class (that is, objects).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are static methods?

A

Also referred to as class methods, they are called this because of how they look in the editor.

static void alert (String prompt)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write down a statement that when executed displays a dialogue box which say “hey! click this!!” and and “OK” button

nothing else!

A

OUDialog.alert(“hey! click this!!”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how is each of the following lines in the sequence executed?

String name;
name = “Patrick”;
name = name.toUpperCase();
OUDialog.alert(“The name was “ + name);

A
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".
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the scope?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do I convert an integer to its string value?

A

String.valueOf(100);

for example

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do i convert a string representation of a integer to its integer value?

A

Integer.parseInt(“1905”);

for example

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a statement block?

A

In an IF statement, the braces { and } and any code between them are called a statement block or just a block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is lazy or short-circuit evaluation?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

in for loops what is the loop control variable?

A

this is in the initialise section of the for loop’s operation control structure, it is the declared variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the roles of the three sections within a for loops operation control structure?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly