NEW
Font size
S
M
L
XL
WorksheetsUNIT 2.2 PROGRAMMING TECHNIQUES
Total questions: 50
Worksheet time: 17mins
Name
Class
Date
1.
Q1: The following is not true about variable names (1-4)
a)
They must be descriptive
b)
They must be in capital letters
c)
They can’t start with numbers or contain spaces
d)
They point to memory locations
2.
Q2: In an assignment operation, this appears on the right hand side (6-9)
a)
Label for a variable that is destination of data
b)
Multiple variables that are destinations for data
c)
Source variables or operations
d)
The assignment operator
3.
Q3: The following is not a valid constant (1-4)
a)
SPACE
b)
PI
c)
UserName
d)
WORDLIMIT
4.
Q4: Which of the following is a valid keyword for output? (1-4)
a)
PRINT
b)
SHOW
c)
DISPLAY
d)
INPUT
5.
Q5: Consider the following expression: a:=b. This means (6-9)
a)
a will always be equal to b
b)
b is being renamed into a
c)
value of memory location a gets copied to memory location b
d)
value of memory location b gets copied to memory location a
6.
Q6: Which of the following is not a valid data type? (1-4)
a)
Real
b)
String
c)
Character
d)
Fraction
7.
Q7: Quotation marks around a variable’s identifier imply (1-4)
a)
It is an integer
b)
It is a string
c)
It is a Boolean
d)
It is a real
8.
Q8: The multiplication table is best displayed using this data type (4-6)
a)
Boolean
b)
Character
c)
Integer
d)
Real
9.
Q9: This variable type can only have True or False values (1-4)
a)
Boolean
b)
Integer
c)
String
d)
Character
10.
Q10: Casting refers to: (4-6)
a)
Boolean algebra
b)
Rounding of reals
c)
Converting between variable data types
d)
Printing out of the program’s results
11.
Q11: The operator used to find if a number is divisible by another number: (4-6)
a)
Integer division
b)
MOD
c)
Division
d)
Subtraction
12.
Q12: The statement A OR B implies A & B are (4-6)
a)
Integers
b)
Strings
c)
Booleans
d)
Characters
13.
Q13: This function calculates the length of a string (4-6)
a)
UBOUND
b)
INDEX
c)
LEN
d)
COUNT
14.
Q14: The following is a correct way to use the MID function (6-9)
a)
A:=MID(“Flower”,”wer”)
b)
A:=MID(4,“Flower”)
c)
A:=MID(“Flower”,4)
d)
A:=MID(“Flower”,4,2)
15.
Q15: The following data types are used in selection conditions & while loops (4-6)
a)
Character
b)
Boolean
c)
Integer
d)
String
16.
Q1: The following is true about Top-down approach
a)
Main procedure is defined first, with other subs to follow
b)
List all operations first, before planning starts
c)
start at the top & complete algorithm by getting to the end
d)
Functions can’t be included as they can’t be called directly
17.
Q2: Structured code has the following benefit
a)
Reduces the number of lines of code
b)
Improves efficiency
c)
Makes code easier to read & debug
d)
All of these options are true
18.
Q3: Variable scope refers to
a)
Variable data type
b)
Variable identifier
c)
Logic errors associated with a variable
d)
Different use of global & local variables
19.
Q4: The advantages of parameter passing don’t include this
a)
The same subprogram can be reused in more cases
b)
Parameter passing makes it easier to use global variables
c)
More flexible coding
d)
Can cut down on the use of wasteful global variables
20.
Q5: The main difference between procedures & functions is
a)
Procedures are usually longer & have more instructions
b)
Functions use parameter passing, while procedures don’t
c)
Functions are more difficult to debug
d)
Functions return values, while procedures don’t
21.
Q6: When a variable first appears outside any subprograms
a)
It is a global variable
b)
It is a local variable
c)
It is a parameter variable
d)
It is not a valid variable
22.
Q7: Converting procedures to functions usually causes these effects
a)
Shorter code
b)
Slows the program down
c)
Reduce number of global variables, more parameter passing
d)
Makes it more difficult to use selection
23.
Q8: From this statement: a:=getChoice() we can see that
a)
getChoice() is a function
b)
getChoice() is a global variable
c)
a is an array
d)
getChoice() is a procedure
24.
Q9: Trying to use a local variable from outside its scope will cause
a)
A global variable to be overwritten by it
b)
A wrong procedure to run
c)
A crash with a report “Unknown variable”
d)
A logical error
25.
Q10: Identify a correct statement:
a)
Global variables waste memory
b)
showResults(choice,cutoff) is a function
c)
An array index is its length
d)
Nested iteration structures share the same counter variable
26.
Q11: ELSE IF keyword is used when
a)
Our selection needs to work with more than three choices
b)
Our selection needs to work with more than two choices
c)
SELECT CASE/SWITCH statement is not available
d)
Using conditional loops
27.
Q12: Identify a correct statement:
a)
SELECT CASE is more popular then IF/ELSE IF/ELSE
b)
We can’t have more than 5 levels of nested IF/ELSE IF/ELSE
c)
SELECT CASE is the same concept as SWITCH
d)
FOR loops are known as condition-controlled iteration
28.
Q13: In the nested selection statements
a)
The inside selection structure gets executed first
b)
The outside selection structure gets executed first
c)
AND & OR are to be avoided
d)
Integers must be used instead of Booleans
29.
Q14: The flowchart shape for selection is
a)
Parallelogram
b)
Square
c)
Diamond
d)
Rounded rectangle
30.
Q15: Identify an invalid expression
a)
ELSE x=45 THEN
b)
IF x>9 & x<100 THEN
c)
Any FOR loop can be rewritten as a WHILE loop
d)
PROCEDURE Test(a AS INTEGER)
31.
Q16: When a FOR loop increments a counter by a number other than one, this is called
a)
Increment
b)
Decrement
c)
Stepping
d)
Condition
32.
Q17: For exiting FOR loops early we use
a)
Nested iteration
b)
BREAK clause
c)
HALT clause
d)
Conditional loops
33.
Q18: The following is not true about arrays
a)
All array elements have the same data type
b)
Array size is fixed, not easily changed while a program runs
c)
Names[LEN(Names)] is the last element of the array Names
d)
The use of iteration makes arrays less relevant
34.
Q19: The following is not a correct statement involving arrays
a)
ARRAY Test[40]
b)
ARRAY Test[56,34,89,8]
c)
ARRAY:= Test[40]
d)
NewArray:=SPLIT(MID(“War & Peace”,2,5),”,”)
35.
Q20: The following is not a correct statement involving arrays
a)
J:=Pupils[5,8]
b)
Nums[i,j]:=Nums[i-1,j]
c)
Nums[i,j]:=Nums[i-1]
d)
B:=getChoices(45)
36.
Q1: In Record structures, VARCHAR keyword means
a)
A field can be any number of characters or bytes in length
b)
Field can be up to a certain number of characters in length
c)
A field is an integer
d)
The name of the field is about to be changed
37.
Q2: The following is true about Records
a)
They must have an index
b)
Fields are made up of records
c)
Records can combine multiple data types in their fields
d)
Record arrays are 2D arrays
38.
Q3: SQL is used to work with files in this format
a)
Plain text
b)
CSV
c)
Proprietary binary
d)
Spreadsheets
39.
Q4: The following is true about SQL
a)
It has loops just like any other language
b)
SQL is case sensitive
c)
SQL is hard to read due to a lot of abbreviated keywords
d)
SQL usually runs on top of another language
40.
Q5: The purpose of SELECT * FROM Pupils WHERE Result>90 is
a)
To set every Pupil’s result to 90
b)
Retrieve records of Pupils, only whose result is 90
c)
Retrieve records of Pupils,only whose result is over 90
d)
Retrieve records of Pupils, only whose name is over 90
41.
Q6: The LIKE operator is used to
a)
Approve SQL statements before execution
b)
Replace the WHERE statement
c)
When we deal with Boolean fields
d)
To use partial matching when searching
42.
Q7: Nested SELECT queries are used
a)
When Boolean operators get too complex
b)
When retrieving data from multiple tables
c)
When using partial matching
d)
For validation & quality control
43.
Q8: When we read or write text files, we are working with this data type
a)
Integers
b)
Booleans
c)
Reals
d)
Strings
44.
Q9: EOF is used in
a)
To indicate the end of a line with a formatting delimiter
b)
Conditional loops when writing to a file
c)
Conditional loops when reading from a file
d)
Destructive overwriting of the file’s data
45.
Q10: The following is not a valid file open mode
a)
Insert
b)
Append
c)
Read
d)
Write
46.
Q11: The following is not a reason to close files
a)
The program will not run otherwise
b)
Unneeded files kept open is wasted memory
c)
If we don’t close a file, we will keep on changing it's data
d)
A proper EOF will not be written
47.
Q12: The following is true about working with text files
a)
The file has to exist before we can write to it
b)
changes are saved when written, not when we close the file
c)
We use counter-controlled loops to read them
d)
We read & write them one line at a time
48.
Q13: The following is a right way to write to a file
a)
myFile.READLINE(variable)
b)
myFile.WRITELINE(variable)
c)
myFile.APPENDLINE(variable)
d)
myFile.INSERTLINE(variable)
49.
Q14: The most appropriate file mode for creating a logbook
a)
Read
b)
Write
c)
Append
d)
Close
50.
Q15: The following is a valid way to write a 2D array to a text file
a)
Concatenate rows to string with commas, write with WRITELINE
b)
Split the text file and copy all elements to the array
c)
Use SQL to convert 2D array to records first
d)
All of these options are valid
Reset
