Glossary Flashcards

1
Q

1) a method

A method is a part of a class and contains a particular set of i___________ .

Normally a method will perform a single well-defined t______.

Methods allow a programer to m____________ a program: to break up a complex program into simpler parts.

A

instructions
task
modularize

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

2) The first line, which declares the method, is called ________________

Example

static void displayMessage() ( This line)
{
System.out.println(“Please note that all information supplied is confidential”);
System.out.println(“No personal details will be shared with any third party”);
}

A

A method header

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

3) This m______ h_______ consists of three words:

static void displayMessage()
(The name that we have given to our method)

A

method header

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

4) static

Methods that have been d________ as static (such as main) can only call other methods in the class
if they too are s______.

A

declared
static

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

5) void

Methods can return information once they t_________, but they don’t have to.
If a method is just doing something simple like displaying a message, then it will not be returning a value.

If a method will not be returning a value, we declare it as v_____.

A

terminate
void

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

6) The naming convention for methods is ____________________

A

lower camel case

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

7) True or False

A method can only be called from within the main method.

A

False
A method can be called by the main method, but it can also be called by any other method.
The called method could in turn call yet another method. This would result in a number of methods being “chained”.

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

8) Methods that are NOT void!

Look at the following method header.

static void displayQuetion( )

Is this method going to return a value?

A

No. The brackets are empty, and it has therefore been named ‘void’.

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

9) Study the following method header

static double addTax(double priceIn, double taxIn)

Is this method going to return a value?

A

Yes!

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

10) What value will be returned by the following method?

static double addTax(double priceIn, double taxIn)
{
return priceIn * (1 + taxIn/100);
}

A

The new price of the item, including tax.

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

11) Why do we have the word ‘double’ instead of ‘void’?

static double addTax(double priceIn, double taxIn)
{
return priceIn * (1 + taxIn/100);
}

A

Because we will be returning a value as a double, e.g. £3.50
The variable ‘price’, which will have been declared earlier in the program will have been declared as a double.

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

12) The variables declared in the (brackets of a method) are called:

f______________ p_______________ of the method.

A

formal parameters

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

13) Which suffix is conventionally added to variable names within a method’s formal parameters?

e.g. ‘tax’ would become…

A

-IN
taxIN

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

14) return

Study the following method:

static double addTax(double priceIn, double taxIn)
{
return priceIn * (1 + taxIn/100);
}

The word ‘return’ in the body of the method serves two very important functions:

1) It t____________ the method
2) It s__________ b_________ a value

A

terminates
sends back

Notice, the return statement can also perform calculations!
e.g. return priceIn * (1 + taxIn/100);

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

15) Local Variables

As we learned in week 1, variables are only visible within the curly braces in which they were declared.
So, the variables declared inside particular sets of brackets are called
l_________ v____________

A

local variables

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

16) Because the visibility of variables is limited to a particular part of a program, we say that variables have a
s__________.

A

scope

17
Q

17) Overloading

Overloading means using something like a + operator to do more than one thing

e.g. A + operator can add numbers together and it can c______________

A

concatenate

18
Q

18) Object-oriented programming consists of defining one or more classes that may i_______ with each other.

A

interact

19
Q

19) private

The keyword ‘private’ plays an important role in encapsulation.

Access to o_______ data is controlled via m________ and using the keywords ‘private’ and ‘Class’.

Attributes are often declared private to the class, and the methods that the class allows the outside world to use are declared public.

e.g.
public class Square
{ \ the attributes
private int size;
private int xPosition;
private int yPosition;
private String color;

          \\the methods

 public void moveDown()
 {
     moveVertical(20);
 }
 ……. }
A

object
methods

20
Q

20) A programming Paradigm is:

A s___________ of programming.

A

style

e.g. Object oriented programming
structured programming
functional programming
etc