CSE 1321 EXAMS SCRIPT 2026/2027 QUESTIONS AND
SOLUTIONS RATED A+
✔✔Array indexes always starts at what value? - ✔✔0
✔✔What will be the value of x[3] after the following code has been executed?
Create array x [5]
y←0
FOR (i = 0, i < 5, i++)
x[i] ← y
y ← y + 10
ENDFOR - ✔✔x = [0,10,20,30,40]
x[3] is 30
Answer: 30
✔✔What will be the results of the following code?
ARRAY_SIZE ← 5
Create array x [ARRAY_SIZE]
FOR (int i = 0, i < length of x, i++)
x[i] ← 10
ENDFOR - ✔✔All the values in the array are initialized to 10
✔✔What would be the results of the following code?
Create array1 ← [33, 88, 11, 44, 99, 55]
value ← array1[0]
FOR (int i = 0, i < length of array1, i++)
IF(array1[i] < value) THEN
value ← array1[i]ENDIFENDFOR - ✔✔Value contains the lowest value in array1.
✔✔What would be the value of x[1] after the following code is executed?
Create array x [22, 33, 44]
CALL ARRAY_PROCESS with x
...
METHOD ARRAY_PROCESS(parameter [] a)
BEGIN
FOR (int i = 0, i < length of x, i++)
a[i] ←a[i] + 5
ENDFOR
END ARRAY_PROCESS - ✔✔38
✔✔For the following code, what would be the value of str[2]?
, Create array myStrings ← ["abc", "def", "ghi", "jkl"] - ✔✔A reference to the string "ghi"
✔✔The index of the center position of a 3*3 2D array would be: - ✔✔[1][1]
✔✔Choose the answer that best describes the array created upon executing the
following:
Create array myStudents[30][6] - ✔✔Creates a 2D array with 30 rows and six columns
✔✔What value is stored in myNumbers[1][2] after the following code executes:
y←3
Create array myNumbers[3][4]FOR rows in myNumbersFOR columns in myNumbers
myNumbers ← y y ← y + 2
ENDFORENDFOR - ✔✔15
✔✔Select the code you would use to create a 2D array with 5 rows and 12 columns. -
✔✔Create array myNums[5][12]
✔✔The visibility level of a class field should be. - ✔✔private
✔✔A field can be of any data type that is legal in the language you are using. - ✔✔True
✔✔A class field is also known as a(n): - ✔✔attribute
✔✔A class is analagous to a(n) - ✔✔blueprint
✔✔An object is a(n) - ✔✔instance of the class
✔✔This is a method that is automatically called when an instance of a class is created. -
✔✔constructor
✔✔If you write a constructor for a class, it should initialize all class fields. - ✔✔True (not
false, "should")
✔✔This keyword is used to indicate a field belongs to a class, and not an instance. -
✔✔static
✔✔The new keyword makes a call to a class's constructor. - ✔✔True
✔✔Each instance of a class has its own set of fields. - ✔✔True
SOLUTIONS RATED A+
✔✔Array indexes always starts at what value? - ✔✔0
✔✔What will be the value of x[3] after the following code has been executed?
Create array x [5]
y←0
FOR (i = 0, i < 5, i++)
x[i] ← y
y ← y + 10
ENDFOR - ✔✔x = [0,10,20,30,40]
x[3] is 30
Answer: 30
✔✔What will be the results of the following code?
ARRAY_SIZE ← 5
Create array x [ARRAY_SIZE]
FOR (int i = 0, i < length of x, i++)
x[i] ← 10
ENDFOR - ✔✔All the values in the array are initialized to 10
✔✔What would be the results of the following code?
Create array1 ← [33, 88, 11, 44, 99, 55]
value ← array1[0]
FOR (int i = 0, i < length of array1, i++)
IF(array1[i] < value) THEN
value ← array1[i]ENDIFENDFOR - ✔✔Value contains the lowest value in array1.
✔✔What would be the value of x[1] after the following code is executed?
Create array x [22, 33, 44]
CALL ARRAY_PROCESS with x
...
METHOD ARRAY_PROCESS(parameter [] a)
BEGIN
FOR (int i = 0, i < length of x, i++)
a[i] ←a[i] + 5
ENDFOR
END ARRAY_PROCESS - ✔✔38
✔✔For the following code, what would be the value of str[2]?
, Create array myStrings ← ["abc", "def", "ghi", "jkl"] - ✔✔A reference to the string "ghi"
✔✔The index of the center position of a 3*3 2D array would be: - ✔✔[1][1]
✔✔Choose the answer that best describes the array created upon executing the
following:
Create array myStudents[30][6] - ✔✔Creates a 2D array with 30 rows and six columns
✔✔What value is stored in myNumbers[1][2] after the following code executes:
y←3
Create array myNumbers[3][4]FOR rows in myNumbersFOR columns in myNumbers
myNumbers ← y y ← y + 2
ENDFORENDFOR - ✔✔15
✔✔Select the code you would use to create a 2D array with 5 rows and 12 columns. -
✔✔Create array myNums[5][12]
✔✔The visibility level of a class field should be. - ✔✔private
✔✔A field can be of any data type that is legal in the language you are using. - ✔✔True
✔✔A class field is also known as a(n): - ✔✔attribute
✔✔A class is analagous to a(n) - ✔✔blueprint
✔✔An object is a(n) - ✔✔instance of the class
✔✔This is a method that is automatically called when an instance of a class is created. -
✔✔constructor
✔✔If you write a constructor for a class, it should initialize all class fields. - ✔✔True (not
false, "should")
✔✔This keyword is used to indicate a field belongs to a class, and not an instance. -
✔✔static
✔✔The new keyword makes a call to a class's constructor. - ✔✔True
✔✔Each instance of a class has its own set of fields. - ✔✔True