importjava.util.Scanner;classMatrixMultiplication{publicstaticint[][]getMatrix(int rows,int cols){Scanner scanner =newScanner(System.in);int[][] matrix =newint[rows][cols];for(int i =0; i < rows; i++){for(int j =0; j < cols; j++){ matrix[i][j]= scanner.nextInt();}}return matrix;}publicstaticvoidprintMatrix(int[][] matrix){for(int i =0; i < matrix.length; i++){for(int j =0; j < matrix[0].length; j++){System.out.print(matrix[i][j]+" ");}System.out.println();}}publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);System.out.print("Enter no of rows and cols of matrix A: ");int a_rows = scanner.nextInt();int a_cols = scanner.nextInt();int b_rows = a_cols;System.out.print("Enter no of cols of matrix B: ");int b_cols = scanner.nextInt();System.out.println("Enter elements of matrix A:");int[][]A=getMatrix(a_rows, a_cols);System.out.println("Enter elements of matrix B:");int[][]B=getMatrix(b_rows, b_cols);int[][]C=newint[a_rows][b_cols];for(int i =0; i < a_rows; i++){for(int j =0; j < b_cols; j++){for(int k =0; k < a_cols; k++){C[i][j]+=A[i][k]*B[k][j];}}}System.out.println("\nMatrix A:");printMatrix(A);System.out.println("\nMatrix B:");printMatrix(B);System.out.println("\nProduct of matrix A & B:");printMatrix(C);}}