Java6a (1) (1) (1)

.docx

School

CUNY Bronx Community College *

*We aren’t endorsed by this school

Course

MISC

Subject

Mathematics

Date

Apr 3, 2024

Type

docx

Pages

7

Uploaded by ConstableKookaburaPerson1027 on coursehero.com

Q1: Information is passed to a method in: a. the method name. b. that method's return. c. the method body. d. the arguments to the method. Q2: Programs designed for maintainability are constructed from small simple pieces or modules. Modules in Java are called: a. methods. b. classes. c. arguments. d. both methods and classes. Q3: A well-designed method a. performs multiple unrelated tasks. b. repeats code found in other methods. c. contains thousands of lines of code. d. performs a single, well-defined task. Q4: To declare a method as static, place the keyword static before ________ in the method’s declaration. a. the method modifier. b. the return type. c. the method name. d. the argument list. Q5: Which is a correct static method call of Math class method sqrt? a. sqrt( 900 ); . b. math.sqrt( 900 ); . c. Math.sqrt( 900 ); . d. Math math = new Math(); math.sqrt( 900 ); . Q6: Which of the following methods is not in the Math class? a. ceil . b. abs . c. parseInt . d. log . Q7: Which of the following can be an argument to a method? a. Constants. b. Variables. c. Expressions. d. All of the above. Q8: Method log takes the logarithm of its argument with respect to what base? a. 10
b. e c. 2 d. pi Q6: Any field declared with keyword ________ is constant. a. static . b. cons . c. constant . d. final . Q7: Declaring main as ________ allows the JVM to invoke main without creating an instance of the class. a. public . b. void . c. static . d. final . Q8: Variables should be declared as fields only if a. they are local variables. b. they are used only within a method. c. they are required for use in more than one method or their values must be saved between calls to the class’s methods. d. they are arguments. Q9: Consider the following Java statements: int x = 9; double y = 5.3; result = calculateValue( x, y ); Which of the following statements is false? a. A method is called with its name and parentheses. b. x and y are parameters. c. Copies of x and y are passed to the method calculateValue() . d. x and y are arguments. Q10: The parameter list in the method header and the arguments in the method call must agree in: a. number b. type c. order d. all of the above Q11: Which operator can be used in string concatenation? a. * . b. += . c. ++ . d. =+ .
Q12: When an object is concatenated with a String : a. a compilation error occurs. b. a runtime error occurs. c. the object’s toString method is implicitly called to obtain the String representation of the object. d. the object’s class name is used. Q13: A static method can ________. a. call only other static methods of the same class directly. b. manipulate only static fields in the same class directly. c. be called using the class name and a dot ( . ). d. All of the above. ANS: d. All of the above. Q14: Which statement is false? a. If a method does not return a value, the return-value-type in the method declaration can be omitted. b. Placing a semicolon after the right parenthesis enclosing the parameter list of a method declaration is a syntax error. c. Redeclaring a method parameter as a local variable in the method’s body is a compilation error. d. Forgetting to return a value from a method that should return a value is a compilation error. Q15: Stacks are known as ________ data structures. a. FIFO. b. FILO. c. LIFO. d. LILO. Q16: If more method calls occur than can have their activation records stored on the program execution stack, an error known as a ________ occurs. a. stack overflow. b. stack rewind. c. stack full. d. stack empty. Q17: Which of the following promotions of primitive types is NOT allowed to occur? a. char to int . b. int to double . c. short to long . d. double to float . Q18: Which of the following primitive types is never promoted to another type? a. double .
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help