1.2 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

1.2.4
1) What is string manipulation?
2) What is the command to get a string length?
3) What is the command to extract part of a string?

A

1) The act of manipulating, extracting, or changing the characters in a string variable.
2) To get the length of the string: stringName.length
3) To extract part of a string: string.substring (starting position, number of characters)

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

1.2.4
1) What is a procedure?
2) What is a function?
3) How does a return value work?

A

1) A procedure is a named block of code that performs a task, but does not return a value.
2) A function is a named block of code that returns a value.
3) A return value can be used directly without being assigned to variable first. Some programming languages allow just one value to be returned, while others support multiple return values.

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

1.2.4
1) What is a local variable?
2) Can local variables have the same identifier?

A

1) A local variable is a varible that is only accessible within a specific part of a program. These variables are usually local to a subroutine and are declared or defined within that routine.
2) Local variables in different subroutines are allowed to have the same identifier (name). Each variable’s data is stored in separate places in main memory, so changing the value of a local variable one subroutine will not affect the value of of any local variables with the same identifier in their subroutines.

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

1.2.4
1) What is a global variable?
2) Is it better to use local or global variables?

A

1) A global variable can be accessed anywhere in a program for the duration of the program’s execution. A global variable has a global has a global scope.
2) Programs using global variables are more difficult to debug, as the variables can be updated in any part of the program. It is almost always better to use local variables and to pass values between subroutine to avoid errors caused by unforeseen changed.

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