Quizzes

MIDTERM QUIZ 1

Score for this quiz: 23 out of 30

MIDTERM QUIZ 2

Score for this quiz: 38 out of 45
Submitted Mar 27 at 5:32pm
This attempt took 27 minutes.

Question 1
Score: 0 / 1
What method is used to read a string from Console?
Answer: Scanner
Question 2
Score: 1 / 1
Which Scanner method reads a floating-point number?
Answer: nextFloat()
Question 3
Score: 0 / 1
What keyword is used to import the Scanner class?
Answer: import
Question 4
Score: 1 / 1
Which method reads a single word using Scanner?
Answer: next()
Question 5
Score: 1 / 1
What is the purpose of closing input streams?
Answer: To avoid memory leaks
Question 6
Score: 1 / 1
What Scanner method reads long values?
Answer: nextLong()
Question 7
Score: 1 / 1
What is the primary function of the BufferedReader class?
Answer: To buffer and read text input
Question 8
Score: 1 / 1
Which of the following refers to data provided to a computer system for processing?
Answer: Input
Question 9
Score: 1 / 1
If a programmer writes java MyProgram 10 20, will the values 10 and 20 be treated as integer types directly by the JVM?
Answer: False
Question 10
Score: 1 / 1
Which input method is best suited for password input without displaying characters?
Answer: Console
Question 11
Score: 1 / 1
Which method is used to read an entire line using Scanner?
Answer: nextLine()
Question 12
Score: 1 / 1
What class provides parsing methods like nextInt() and nextDouble()?
Answer: Scanner
Question 13
Score: 1 / 1
Which class wraps System.in to read input in BufferedReader?
Answer: InputStreamReader
Question 14
Score: 1 / 1
What is the wrapper class used before BufferedReader?
Answer: InputStreamReader
Question 15
Score: 1 / 1
If a developer forgets to wrap System.in with InputStreamReader before using BufferedReader, will the program still compile and run correctly?
Answer: False
Question 16
Score: 1 / 1
Which of the following is NOT a type of control structure?
Answer: Compilation
Question 17
Score: 1 / 1
Which loop checks the condition after execution?
Answer: do-while
Question 18
Score: 1 / 1
What is required for a loop to continue?
Answer: True condition
Question 19
Score: 1 / 1
Statement used for multiple selections.
Answer: switch statement
Question 20
Score: 1 / 1
What does continue do?
Answer: Skips iteration
Question 21
Score: 1 / 1
Keyword that exits a loop.
Answer: break
Question 22
Score: 0 / 1
A chain of conditions forming a decision tree.
Answer: nested if
Question 23
Score: 1 / 1
switch can replace if-else-if.
Answer: True

Question 24
Score: 1 / 1
Infinite loops never stop unless controlled.
Answer: True
Question 25
Score: 1 / 1
Keyword that skips the current iteration.
Answer: continue
Question 26
Score: 1 / 1
Which loop executes at least once?
Answer: do-while
Question 27
Score: 1 / 1
The if statement only runs when the condition is true.
Answer: True
Question 28
Score: 1 / 1
Which loop is best when iterations are known?
Answer: for
Question 29
Score: 0 / 1
Statement used to evaluate conditions and control execution.
Answer: control statement
Question 30
Score: 0 / 1
What will be the output?
Answer: error
Question 31
Score: 1 / 1
If a programmer defines a method to calculate the sum of two numbers, is it necessary to include a return statement when it has a non-void return type?
Answer: True
Question 32
Score: 1 / 1
What Java class provides methods like max(), min(), and sqrt()?
Answer: Math class
Question 33
Score: 1 / 1
What is the index of the first element in an array?
Answer: 0
Question 34
Score: 0 / 1
What is the value of matrix[1][2] in a 2D array?
Answer: Second row, third column
Question 35
Score: 1 / 1
What does Arrays.sort() do?
Answer: Sorts array elements
Question 36
Score: 1 / 1
If a method is declared as private, can it be accessed directly from another class outside its package?
Answer: False
Question 37
Score: 0 / 1
When using predefined methods such as Math.max() or Math.sqrt(), is it required to define them manually?
Answer: False
Question 38
Score: 1 / 1
If a method is declared as static, can it be called without creating an object?
Answer: True
Question 39
Score: 1 / 1
Which access modifier allows a method to be accessed everywhere?
Answer: public
Question 40
Score: 1 / 1
If a method returns a value, is it optional to store that value in a variable?
Answer: True
Question 41
Score: 1 / 1
What keyword is used when a method does not return a value?
Answer: void
Question 42
Score: 1 / 1
What is used to call or execute a method?
Answer: method call
Question 43
Score: 1 / 1
What is the purpose of parameters in a method?
Answer: To accept input values
Question 44
Score: 1 / 1
What do you call a block of code that performs a specific task in Java?
Answer: method
Question 45
Score: 1 / 1
When modifying an array element using its index, does the new value replace the previous value?
Answer: True