Starting Out with Java From Control Structures through Objects 6th Edition Gaddis Test Bank - Quick Download In Full PDF Format With All Chapters
Starting Out with Java From Control Structures through Objects 6th Edition Gaddis Test Bank - Quick Download In Full PDF Format With All Chapters
com
https://testbankfan.com/product/starting-out-with-java-from-
control-structures-through-objects-6th-edition-gaddis-test-
bank/
OR CLICK BUTTON
DOWLOAD NOW
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-objects-6th-edition-gaddis-solutions-manual/
testbankfan.com
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-objects-7th-edition-gaddis-test-bank/
testbankfan.com
https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-objects-7th-edition-gaddis-solutions-manual/
testbankfan.com
https://testbankfan.com/product/abnormal-psychology-and-life-a-
dimensional-approach-1st-edition-kearney-test-bank/
testbankfan.com
Technology In Action Introductory 14th Edition Evans Test
Bank
https://testbankfan.com/product/technology-in-action-
introductory-14th-edition-evans-test-bank/
testbankfan.com
https://testbankfan.com/product/general-organic-and-biochemistry-9th-
edition-denniston-test-bank/
testbankfan.com
https://testbankfan.com/product/introduction-to-sociology-4th-edition-
ritzer-test-bank/
testbankfan.com
https://testbankfan.com/product/managerial-economics-and-strategy-2nd-
edition-perloff-test-bank/
testbankfan.com
https://testbankfan.com/product/foundations-of-astronomy-13th-edition-
seeds-test-bank/
testbankfan.com
What is Psychology Foundations Applications and
Integration 3rd Edition Pastorino Test Bank
https://testbankfan.com/product/what-is-psychology-foundations-
applications-and-integration-3rd-edition-pastorino-test-bank/
testbankfan.com
Starting Out with Java: From Control Structures through Objects, 6e (Gaddis)
Chapter 5 Methods
2) Which of the following is NOT a benefit derived from using methods in programming?
A) Pproblems are more easily solved.
B) simplifies programs
C) code reuse
D) All of the above are benefits.
Answer: D
3) This type of method performs a task and sends a value back to the code that called it.
A) value-returning
B) void
C) complex
D) local
Answer: A
1
Copyright © 2016 Pearson Education, Inc.
6) In the header, the method name is always followed by this:
A) parentheses
B) return type
C) data type
D) braces
Answer: A
7) This part of a method is a collection of statements that are performed when the method is executed.
A) method header
B) return type
C) method body
D) method modifier
Answer: C
9) If method A calls method B, and method B calls method C, and method C calls method D, when
method D finishes, what happens?
A) Control is returned to method A.
B) Control is returned to method B.
C) Control is returned to method C.
D) The program terminates.
Answer: C
2
Copyright © 2016 Pearson Education, Inc.
12) What is wrong with the following method call?
13) Given the following method header, which of the method calls would be an error?
14) Which of the following would be a valid method call for the following method?
3
Copyright © 2016 Pearson Education, Inc.
17) A special variable that holds a value being passed into a method is called what?
A) Modifier
B) Parameter
C) Alias
D) Argument
Answer: B
18) When you pass an argument to a method, be sure that the argument's data type is compatible with:
A) the parameter variable's data type
B) the method's return type
C) the version of Java currently being used
D) IEEE standards
Answer: A
22) Which of the following values can be passed to a method that has an int parameter variable?
A) float
B) double
C) long
D) All of the above
E) None of the above
Answer: E
4
Copyright © 2016 Pearson Education, Inc.
23) The header of a value-returning method must specify this.
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
Answer: C
26) When a method tests an argument and returns a true or false value, it should return:
A) a zero for true and a one for false
B) a boolean value
C) a zero for false and a non-zero for true
D) a method should not be used for this type test
Answer: B
5
Copyright © 2016 Pearson Education, Inc.
29) Breaking a program down into small manageable methods:
A) makes problems more easily solved
B) allows for code reuse
C) simplifies programs
D) all of the above
Answer: D
int num;
string str = "555";
num = Integer.parseInt(str) + 5;
A) a value-returning method
B) a void method
C) a local variable
D) a complex method
Answer: A
34) You should always document a method by writing comments that appear:
A) just before the method's definition
B) just after the method's definition
C) at the end of the file
D) only if the method is more than five lines long
Answer: A
6
Copyright © 2016 Pearson Education, Inc.
35) 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
Answer: B
36) If you attempt to use a local variable before it has been given a value:
A) a compiler error will occur
B) the local variable will always contain the value 0
C) the results will be unpredictable
D) the local variable will be ignored
Answer: A
int num;
string str = "555";
num = Integer.parseInt(string str) + 5;
A) num will be set to 560.
B) str will have a value of "560".
C) The last line of code will cause an error.
D) Neither num or str will be changed.
Answer: C
38) Given the following method header, which of the method calls would be an error?
39) Which of the following would be a valid method call for the following method?
7
Copyright © 2016 Pearson Education, Inc.
40) When writing the documentation comments for a method, you can provide a description of each
parameter by using a:
A) @comment tag
B) @doc tag
C) @param tag
D) @return tag
Answer: C
43) A value-returning method must specify this as its return type in the method header.
A) an int
B) a double
C) a boolean
D) any valid data type
Answer: D
45) To document the return value of a method, use this in a documentation comment.
A) The @param tag
B) The @comment tag
C) The @return tag
D) The @returnValue tag
Answer: C
8
Copyright © 2016 Pearson Education, Inc.
46) The process of breaking a problem down into smaller pieces is sometimes called:
A) divide and conquer
B) scientific method
C) top-down programming
D) whole-into-part
Answer: A
47) Any method that calls a method with a throws clause in its header must:
A) handle the potential exception
B) have the same throws clause
C) both of the above
D) do nothing, the called program will take care of the throws clause
Answer: C
48) Assume that the following method header is for a method in class A.
Assume that the following code segments appear in another method, also in class A. Which contains a
legal call to the displayValue method?
A) int x = 7;
void displayValue(x);
B) int x = 7;
displayValue(x);
C) int x = 7;
displayValue(int x);
D) int x = 7;
displayValue(x)
Answer: B
1) Methods are commonly used to break a problem into small manageable pieces.
Answer: TRUE
2) Two general categories of methods are void methods and value returning methods.
Answer: TRUE
3) In the method header, the method modifier public means that the method belongs to the class, not a
specific object.
Answer: FALSE
4) Constants, variables, and the values of expressions may be passed as arguments to a method.
Answer: TRUE
9
Copyright © 2016 Pearson Education, Inc.
6) You must have a return statement in a value-returning method.
Answer: TRUE
7) 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.
Answer: TRUE
8) In the method header the static method modifier means the method is available to code outside the
class.
Answer: FALSE
10) No statement outside the method in which a parameter variable is declared can access the parameter
by its name.
Answer: TRUE
11) The expression in a return statement can be any expression that has a value.
Answer: TRUE
10
Copyright © 2016 Pearson Education, Inc.
Random documents with unrelated
content Scribd suggests to you:
fishing, he asked a lad who had shown him a trout pool in a stream
with great success, to show him another. It was eight o’clock, and
the child replied, “No, I must go grade home.” I made him repeat
the word two or three times, until he became angry, thinking I was
laughing at him, and then he changed the word, saying, “I must just
go straight home.” I have never had a more delightful table
companion than Mr. Gladstone, and he himself was so eager in
telling me about the derivations of various words that he overlooked
his dinner.
I was shooting with Redvers Buller at Castle Rising on the 29th
240
November, when I had a flattering letter from Lord Granville,
saying that Mr. Gladstone wished me to go out and recreate the
Egyptian Army. This was the more complimentary on his part, as I
had disagreed with him strongly about his Irish policy.
I went to London, and after a discussion by telegraph with Lord
Dufferin, who wished to give me only half the salary I was willing to
accept, went out on my own terms. When I reached Cairo, Lord
Dufferin told me that although he had used the name of the
Egyptian Government, it was he who had tried to get me at a small
salary, and three months later he was good enough to say I was
cheap at any price.
Chinese Gordon wrote on the 8th of December, when sending
me a present of a gold-laced coat which the late Khedive gave to
him, “I am so truly glad you are going out. For go you will.
Remember you are creating there a British contingent.” In a P.S. he
urged I should be very careful in my choice of a Native writer, about
241
which I will later narrate something which happened in 1884.
Just before Christmas I was back again in Cairo, and taking
steps to raise the Egyptian Army, which had been disbanded after
Tel-el-Kebir.
CHAPTER XLI
1883—SIRDAR
testbankfan.com