☑Kizspy.me
SWT301_SU25_PE1_190415
Intructions:
• You need to know at least one programming language to perform reasonably well on
certain exam questions.

Students are not allowed to use IDEs such as NetBeans, IntelliJ IDEA, or similar software
to do the test.
• All the answers must be written in the provided template file, in Enghlish and reflect
this exam paper. If your answers to the questions in this exam paper have any keywords
not related to this electronic exam paper, the answers to the questions will get ZERO. If
you do not use the provided template file to answer the exam you take today, your
exam will get ZERO.
Question 1 (3 points): Review the following class and find (at least) 6 issues in the code (i.e,
coding practice, compile errors, potential logical issue, etc.) (Use question 1 template)
Steps for Matrix Multiplication in Java
• Define matrix dimensions - Ensure the number of columns in the first matrix matches the
number of rows in the second matrix.
• Multiply and sum elements - For each element in the resulting matrix, take the dot product
.
1.
2.
3.
4.
5.
of the corresponding row from the first matrix and the column from the second matrix.
Construct the result matrix - Place the computed values into their respective positions in
the new matrix.
class matrixMultiplication {
public static int[] [] multiplyMatrices (int [ ] [ ] A, int [ ] [ ] B) {
int m A.length; n A[0].length; p - B[e].length;
if (A[0].length - B.length) {
throw new IllegalArgumentException("The number of columns of matrix A must equal the number of
rows of matrix B.");
}
6.
7.
8.
9.
for (int i = 0; i < m; 1) {
int[][] C new int[=][p];
Zoom
+ 100%
Close