91%(22)20 out of 22 people found this document helpful
This preview shows page 1 - 3 out of 390 pages.
gic and Design, 8th EditionChapter 9Review Questions1Which of the following is true?A program can call one method at most.A method can contain one or more other methods.A program can contain a method that calls another method.All of the above are true.2Which of the following must every method have?a parameter lista headera return valueall of the above3abstractobject-orientedprogram levelin scope4a value in a method calla passed constanta formal parametera variable that is local to a method5A method’s interface is its _____.parameter listreturn typeidentifierall of the above6When you write the declaration for a method that can receive a parameter, which of the following mustthe name of the argument that will be used to call the methoda local name for the parameterthe data type of the parametertwo of these7When you use a variable name in a method call, it _____ as the variable in the method header.can have the same namecannot have the same namemust have the same namecannot have the same data type8myMethod(12)myMethod(12, "Hello")myMethod("Goodbye")It is impossible to tell.Which of the following is most closely related to the concept of local?Although the terms parameterand argumentare closely related, the difference is that argumentrefers tAssume you have written a method with the header void myMethod(num a, string b). Whi
9numstringvoid10myMethod()myMethod(test)myMethod(test, test)myMethod(test,"A")11be numericbe a variablematch the data type used before the method name in the headertwo of the above12When a method receives a copy of the value stored in an argument used in the method call, it means thunnamedpassed by valuepassed by referenceassigned its original value when it was declared13A void method _____.contains no statementsrequires no parametersreturns nothinghas no name14When an array is passed to a method, it is _____.passed by referencepassed by valueunnamed in the methodunalterable in the method15When you overload a method, you write multiple methods with the same_____.nameparameter listnumber of parametersreturn type16num calculateTaxes(string name, num amount)string calculateTaxes(num money, string taxpayer)num calculateTaxes(num annualPay, string taxpayerId)All of these can coexist without ambiguity.17Methods in the same program with identical names and identical parameter lists are _____.overloadedoverworkedoverwhelmedambiguous18Methods in different programs with identical names and identical parameter lists are _____.overloadedAssume you have written a method with the header numyourMethod(string name, num codnumand stringAssume you have written a method with the header string myMethod(num score, string The value used in a method’s returnstatement must _____.