CS160 Midterm Exam Newest / CS160 Midterm Exam
Preparation / CS160 Midterm Practice Exam With
Complete 200 Questions And Correct Detailed
Answers |Already Graded A+(Latest Version!!!)||
Verified Exam!!!
1) If a program compiles fine, but it produces incorrect
result, then the program suffers ________. a.a logic error.
b.a compilation error. c.a runtime error. d. a migraine
headache. - Answer-a.a logic error.
2) What is wrong with the following method call?
displayValue (double x); A) There is nothing wrong with the
statement B) x should be a string C) The data type of the
argument x should not be included in the method call D)
displayValue will not accept a parameter - Answer-C) The
data type of the argument x should not be included in the
method call
3) Suppose your method does not return any value, which
of the following keywords can be used as a return type?
A) int B) double C) public D) void E) None of the above -
Answer-D) void
, 2|Page
4) Which of the following lists contains all Java keywords?
a. string, case, import, finally b. Class, Double, Integer,
String, Math c. public, static, void, main d. try, throw, catch,
final - Answer-d. try, throw, catch, final
5) Which of the following would be a valid method call for
the following method?
public void showProduct(double num1, int num2)
{
double product;
product = num1 * num2;
System.out.println("The product is " + product); }
a. showProduct("5", "40"); b. showProduct(10.0, 4.6); c.
showProduct(10, 4.5); d. showProduct(3.3, 55); - Answer-
d. showProduct(3.3, 55);
6) What would be the results of the following code? int[] x
= { 55, 33, 88, 22, 99, 11, 44, 66, 77 }; int a = 10; if(x[2] >
x[5]) a = 5; else a = 8;
a. a = 5 b. a = 8 c. a = 10 d. This is a compilation error,
you cannot compare array elements - Answer-a. a = 5