BCIS 3630 exam only
!What will be returned from the following method?public double methodA(){double a = 8.5 + 9.5;return a;} Select one: a. 18.0 b. 18 (as an integer) c. 8 d. This is an error
a
!What will be the value of x after the following code is executed? int x, y = 15;x = y--; a 15 b 16 c 0 d 14
a
!When an object, such as a String, is passed as an argument, it is a. actually a reference to the object that is passed b. passed by value like any other parameter value c. encryptedd. necessary to know exactly how long the string is when writing the program
a
'A variable that receives a value that is passed into a method is known as a(n).... a parameter b argument c signal d return value
a
`The body of a method is enclosed in a curly braces b square brackets c parentheses d quotation marks
a
`The for loop is this type of loop a pretest b posttest c prefix d postfix
a
`The while loop is this type of loop a pretest b posttest c prefix d postfix
a
`This expression is executed by the for loop only once, regardless of the number of iterations. a initialization expression b test expression c update expression d pre-increment expressoin
a
`This is a special value that signals when tere are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list. a sentinel b flag c signal d accumulator
a
`This is a variable that controls the number of iterations performed by a loop. a loop control variable b switch c argument d method
a
`What will the println statement in the following program segment display? int x=5 System.out.println(x++); a 5 b 6 c 0 d none of these
a
! Before entering a loop to compute a running total, the program should first a read all the values into main memory b set the accumulator variable to an initial value, often zero c set all variables to zero d know exactly how many values there are to total
b
! Given the following method header, which of these method calls is INCORRECT? public void displayValue(int x, int y); a all of these would give an error b displayValue (a, b); //where a is a short and b is a long c displayValue (a,b); // where a is an int and b is a byte d displayValue (a,b); // where a is a short and b is a byte
b
!The ________ loop is ideal in situations where the exact number of iterations is known. a while b for c if d do while
b
!Values that are sent into a method are called ____________. Select one: a. variables b. arguments c. literals d. types
b
!When an argument value is passed to a method, the receiving parameter variable is a. declared within the body of the method b. declared in the method header inside the parentheses c. declared in the calling method d. uses the declaration of the argument
b
'A value that is passed into a method when it is calle is know as a(n).... a parameter b argument c signal d return value
b
'This javadoc tag is used to document a parameter variable a @parameter b @param c @paramvar d @arg
b
Methods are commonly used to a. speed up the compilation of a program b. break a problem down into small manageable pieces c. emphasize certain parts of the logic d. document the program
b
This type of method performs a task and then terminates. Select one: a. value-returning b. void c. local d. simple
b
` This type of method does not return a value a null b void c empty d anonymous
b
`The do-while loop is this type of loop a pretest b posttest c prefix d postfix
b
`this type of loop always executes at least once. a while b do-while c for d any of these
b
! What will be the value of x after the following code is executed? int x = 10, y = 20; while (y<100) {x+=y;y+= 20;} a 130 b 110 c 210 d 90
c
! When an argument is passed to a method _____ a its value is copied into the methods parameter variable b its value may be changed within the called method c both a and b are correct d neither nor are correct
c
!A method a must have at least two parameter variables b never has parameter variables c may have zero or more parameters d may not have only one parameter variable
c
A method header can contain a method modifiers b the method return type C the method name Da list of parameter declarations e all of these f none of these
e
`What will the println statement in the following program segment display? int x=5 System.out.println(++x); a 5 b 6 c 0 d none of these
B
! When the break statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration. T/F
F
!In the method header, the method modifier public means that the method belongs to the class, not a specific object. T/F
F
! When the continue statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration. T/F
T
!Any method that calls a method with a throws clause in its header must either handle the potential exception or have the same throws clause. T/F
T
!Methods are commonly used to break a problem into small manageable pieces. T/F
T
!The do-while loop is ideal in situations where you always want the loop to iterate at least once. T/F
T
!The do-while loop must be terminated with a semicolon. T/F
T
!Two general categories of methods are void methods and value returning methods. T/F
T
!You must have a return statement in a value-returning method. T/F
T
!The phrase divide and conquer is sometimes used to describe Select one: a. the backbone of the scientific method b. the process of dividing functions c. the process of breaking a problem down into smaller pieces d. the process of using division to solve a mathematical problem
c
!What will be the value of x after the following code is executed?int x = 10;while (x < 100){x += 100;} 10 100 110 90
c
!Which of the following would be a valid method call for the following method? public static void showProduct (int num1, double num2) {int 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);
c
'This type of loop ha no way of ending and repeats until the program is interrupted. a indeterminate b interminable c infinite d timeless
c
The header of a value-returning method must specify ______ a. The method's local variable names b. The name of the variable in the calling program that will receive the returned value c. The data type of the return value d. All of the above
c
`In the expression number ++, the ++ operator is in what mode? a prefix b pretest c postfix d posttest
c
! A ______ type of method performs a task and then terminates a simples b value returning c local d void
d
!A value-returning method must specify ____ as its return type in the method header. Select one: a. an int b. a double c. a boolean d. any valid data type
d
!How many times will the following do-while loop be executed? int x = 11;do{x += 20;}while (x > 100); a 5 b 0 c 4 d 1
d
!Which of the following would be a valid method call for the following method? public static 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);
d
!Which type of method performs a task and sends a value back to the code that called it? a complex b void c local d value-returning
d
'Each repetition of a loop is known as a(n) ________. a repetition b loop c try d iteration
d
'The variable used to keep the running total is called a(n) a sentinel b sum c total d accumulator
d
'This appears at the beginning of a method definition a semicolon b parentheses c body d header
d
'this statement causes a method to end and sends a value back to the statement that called the method. a end b send c exit d return
d
How many times will the following for loop be executed? for(int count = 10; count <= 21; count++) System.out.println("java is great!") a 0 b 11 c 10 d 12
d
What will be printed after the following is executed? for (int number = 5; number<= 15; number+=3) System.out.print(number + ","); a this is an invalid for statement b 5,8, 11, 14,17, c 5,6,7,8,9,10,11,12,13,14,15 d 5,8,11,14
d