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: ScannerQuestion 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: importQuestion 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 leaksQuestion 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 inputQuestion 8
Score: 1 / 1
Which of the following refers to data provided to a computer system for processing?
Answer: InputQuestion 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: FalseQuestion 10
Score: 1 / 1
Which input method is best suited for password input without displaying characters?
Answer: ConsoleQuestion 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: ScannerQuestion 13
Score: 1 / 1
Which class wraps System.in to read input in BufferedReader?
Answer: InputStreamReaderQuestion 14
Score: 1 / 1
What is the wrapper class used before BufferedReader?
Answer: InputStreamReaderQuestion 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: FalseQuestion 16
Score: 1 / 1
Which of the following is NOT a type of control structure?
Answer: CompilationQuestion 17
Score: 1 / 1
Which loop checks the condition after execution?
Answer: do-whileQuestion 18
Score: 1 / 1
What is required for a loop to continue?
Answer: True conditionQuestion 19
Score: 1 / 1
Statement used for multiple selections.
Answer: switch statementQuestion 20
Score: 1 / 1
What does continue do?
Answer: Skips iterationQuestion 21
Score: 1 / 1
Keyword that exits a loop.
Answer: breakQuestion 22
Score: 0 / 1
A chain of conditions forming a decision tree.
Answer: nested ifQuestion 23
Score: 1 / 1
switch can replace if-else-if.
Answer: True
Question 24
Score: 1 / 1
Infinite loops never stop unless controlled.
Answer: TrueQuestion 25
Score: 1 / 1
Keyword that skips the current iteration.
Answer: continueQuestion 26
Score: 1 / 1
Which loop executes at least once?
Answer: do-whileQuestion 27
Score: 1 / 1
The if statement only runs when the condition is true.
Answer: TrueQuestion 28
Score: 1 / 1
Which loop is best when iterations are known?
Answer: forQuestion 29
Score: 0 / 1
Statement used to evaluate conditions and control execution.
Answer: control statementQuestion 30
Score: 0 / 1
What will be the output?
Answer: errorQuestion 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: TrueQuestion 32
Score: 1 / 1
What Java class provides methods like max(), min(), and sqrt()?
Answer: Math classQuestion 33
Score: 1 / 1
What is the index of the first element in an array?
Answer: 0Question 34
Score: 0 / 1
What is the value of matrix[1][2] in a 2D array?
Answer: Second row, third columnQuestion 35
Score: 1 / 1
What does Arrays.sort() do?
Answer: Sorts array elementsQuestion 36
Score: 1 / 1
If a method is declared as private, can it be accessed directly from another class outside its package?
Answer: FalseQuestion 37
Score: 0 / 1
When using predefined methods such as Math.max() or Math.sqrt(), is it required to define them manually?
Answer: FalseQuestion 38
Score: 1 / 1
If a method is declared as static, can it be called without creating an object?
Answer: TrueQuestion 39
Score: 1 / 1
Which access modifier allows a method to be accessed everywhere?
Answer: publicQuestion 40
Score: 1 / 1
If a method returns a value, is it optional to store that value in a variable?
Answer: TrueQuestion 41
Score: 1 / 1
What keyword is used when a method does not return a value?
Answer: voidQuestion 42
Score: 1 / 1
What is used to call or execute a method?
Answer: method callQuestion 43
Score: 1 / 1
What is the purpose of parameters in a method?
Answer: To accept input valuesQuestion 44
Score: 1 / 1
What do you call a block of code that performs a specific task in Java?
Answer: methodQuestion 45
Score: 1 / 1
When modifying an array element using its index, does the new value replace the previous value?
Answer: True