WorksheetsJava program 1 Quiz
Total questions: 10
Worksheet time: 5mins
What does the command-line argument <N> represent in this program?
a) The number of matrices
b) The order (size) of the matrix
c) The maximum value of matrix elements
d) The number of rows only
Which class is used to generate random numbers in the program?
a) Math
b) Random
c) Scanner
d) Utility
Which statement correctly describes rand.nextInt(10) in this program?
a) Generates numbers from 0 to 10
b) Generates numbers from 1 to 10
c) Generates numbers from 0 to 9
d) Generates numbers randomly without a limit
What ensures that both matrices are of the same size for addition?
a) User input validation
b) Same value of N used to generate both matrices
c) Try-catch block
d) Java compiler automatically checks
Which modifier makes the helper methods accessible without creating an object?
a) private
b) static
c) public
d) final
Which function generates the matrices in this program?
a) addMatrices()
b) generateRandomMatrix()
c) printMatrix()
d) main()
Which function is responsible for displaying matrices?
a) addMatrices()
b) generateRandomMatrix()
c) printMatrix()
d) main()
Which package does the Random class belong to?
Why is Integer.parseInt(args[0]) used?
a) To convert a string argument into an integer
b) To generate a random number
c) To parse an integer into a string
d) To check if N is positive
What type of loop is used for matrix traversal in the program?
a) While loop
b) For loop
c) Do-while loop
d) Enhanced for-each loop
