CS160 Midterm 2 review questions with
correct answers
Select the statement in main to assign a command-line argument to String
| | | | | | | | | | | |
lastName. |
| java Player Manny Machado 13 Infielder
| | | | |
A) lastName = "Machado";
| | |
C) lastName = args;
| | |
B) lastName = args[1];
| | |
D) lastName = args|3]; - CORRECT ANSWER✔✔-B
| | | | | |
A(n) ________ is an unexpected incident that stops the normal execution of a
| | | | | | | | | | | | |
program. |
A) exception
|
C) default exception handler
| | |
is an unexpected incident that stops the normal execution of a program.
| | | | | | | | | | |
B) error message
| |
D) exception handler - CORRECT ANSWER✔✔-A
| | | | |
What is output given the user input below?
| | | | | | |
| ›thorin fili kili | |
| System.out.print ("Enter info: "); | | |
, | Scanner keyboard = new Scanner(System.in);
| | | |
| String info = keyboard.nextLine();
| | |
| Scanner inputScnr = new Scanner(info);
| | | |
| int item1 = inputScnr.nextInt();
| | |
| String item = inputScnr.next();
| | |
| String item3 = inputScnr.next();
| | |
| System.out.printIn(item2 + " " + item2 + " " + item1); | | | | | | | | | |
A) kili fili thorin
| | |
B) thorin fili kili
| | |
C) thorin thorin thorin
| | |
D) InputMismatchException - CORRECT ANSWER✔✔-D
| | | |
You can use this method to determine whether a file exists.
| | | | | | | | | |
A) The File class's canOpen method
| | | | |
B) The File class's exists method
| | | | |
C) The Scanner class's exists method
| | | | |
D) The PrintWriter class's fileExists method - CORRECT ANSWER✔✔-B
| | | | | | | |
The call stack is an internal list of all the methods that are currently executing.
| | | | | | | | | | | | | | |
True or false? - CORRECT ANSWER✔✔-True
| | | | |
The automatic conversion of an int type to the corresponding wrapper type
| | | | | | | | | | | |
Integer when being passed as a parameter to a generic class is called
| | | | | | | | | | | |
correct answers
Select the statement in main to assign a command-line argument to String
| | | | | | | | | | | |
lastName. |
| java Player Manny Machado 13 Infielder
| | | | |
A) lastName = "Machado";
| | |
C) lastName = args;
| | |
B) lastName = args[1];
| | |
D) lastName = args|3]; - CORRECT ANSWER✔✔-B
| | | | | |
A(n) ________ is an unexpected incident that stops the normal execution of a
| | | | | | | | | | | | |
program. |
A) exception
|
C) default exception handler
| | |
is an unexpected incident that stops the normal execution of a program.
| | | | | | | | | | |
B) error message
| |
D) exception handler - CORRECT ANSWER✔✔-A
| | | | |
What is output given the user input below?
| | | | | | |
| ›thorin fili kili | |
| System.out.print ("Enter info: "); | | |
, | Scanner keyboard = new Scanner(System.in);
| | | |
| String info = keyboard.nextLine();
| | |
| Scanner inputScnr = new Scanner(info);
| | | |
| int item1 = inputScnr.nextInt();
| | |
| String item = inputScnr.next();
| | |
| String item3 = inputScnr.next();
| | |
| System.out.printIn(item2 + " " + item2 + " " + item1); | | | | | | | | | |
A) kili fili thorin
| | |
B) thorin fili kili
| | |
C) thorin thorin thorin
| | |
D) InputMismatchException - CORRECT ANSWER✔✔-D
| | | |
You can use this method to determine whether a file exists.
| | | | | | | | | |
A) The File class's canOpen method
| | | | |
B) The File class's exists method
| | | | |
C) The Scanner class's exists method
| | | | |
D) The PrintWriter class's fileExists method - CORRECT ANSWER✔✔-B
| | | | | | | |
The call stack is an internal list of all the methods that are currently executing.
| | | | | | | | | | | | | | |
True or false? - CORRECT ANSWER✔✔-True
| | | | |
The automatic conversion of an int type to the corresponding wrapper type
| | | | | | | | | | | |
Integer when being passed as a parameter to a generic class is called
| | | | | | | | | | | |