Filters
Question type

Study Flashcards

Which of the following statements describes block scope?


A) It begins at the opening { of the class declaration and terminates at the closing }.
B) It limits label scope to only the method in which it is declared.
C) It begins at the identifier's declaration and ends at the terminating right brace (}) .
D) It is valid for one statement only.

E) B) and D)
F) A) and C)

Correct Answer

verifed

verified

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

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

Which of the following methods is not in the Math class?


A) ceil
B) abs
C) parseInt
D) log

E) None of the above
F) B) and C)

Correct Answer

verifed

verified

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.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

A set of named constants that start with the value 0 for the first constant and increment by 1 for each subsequent constant can be declared as a(n) ________.


A) class
B) enum
C) enumeration
D) None of the above.

E) A) and C)
F) None of the above

Correct Answer

verifed

verified

Which statement below could be used to simulate the outputs of tossing a quarter to get heads or tails? Suppose randomNumbers is a SecureRandom object.


A) randomNumbers.nextInt(7) ;
B) randomNumbers.nextInt(2) ;
C) randomNumbers.nextInt(1) ;
D) randomNumbers.nextInt(25) ;

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

E) B) and C)
F) C) and D)

Correct Answer

verifed

verified

Which of the following methods are overloaded with respect to one another? Public int max (int a, int b) { … } Public double max (double a, double b) { … } Public int max (int a, int b, int c) { … } Public double max (double a, double b, double c) { … }


A) A and B are overloaded; C and D are overloaded.
B) A and C are overloaded; B and D are overloaded.
C) A, B and C are overloaded.
D) All four methods are overloaded.

E) None of the above
F) All of the above

Correct Answer

verifed

verified

Which of the following statements is false?


A) The Java API consists of packages.
B) The Java API helps programmers avoid "reinventing the wheel."
C) The Java API consists of import declarations.
D) None of the above.

E) C) and D)
F) All of the above

Correct Answer

verifed

verified

Identifiers in Java have ________ and ________ scopes?


A) method, class.
B) class, block.
C) block, statement.
D) statement, file.

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

Java uses class ________ to represent colors using their RGB values.


A) Color
B) Colors
C) RGBColor
D) RGBColors

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

Declaring main as static allows the JVM to invoke main ________.


A) without knowing the name of the class in which main is declared.
B) by creating an object of the class in which main is declared.
C) without creating an instance of the class in which main is declared.
D) None of the above.

E) C) and D)
F) None of the above

Correct Answer

verifed

verified

Overloaded methods always have the same _________.


A) method name
B) return type
C) number of parameters
D) order of the parameters

E) C) and D)
F) B) and C)

Correct Answer

verifed

verified

A

Method log takes the logarithm of its argument with respect to what base?


A) 10
B) e
C) 2
D) pi

E) C) and D)
F) B) and C)

Correct Answer

verifed

verified

The java.text package contains classes for manipulating all of the following items except ________.


A) classes
B) numbers
C) strings
D) characters

E) B) and C)
F) C) and D)

Correct Answer

verifed

verified

Which of these statements best defines scope?


A) Scope refers to the classes that have access to a variable.
B) Scope determines whether a variable's value can be altered.
C) Scope is the portion of a program that can refer to an entity by its simple name.
D) Scope allows the programmer to use a class without using its fully qualified name.

E) A) and B)
F) A) and D)

Correct Answer

verifed

verified

Which of the following statements 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.

E) B) and C)
F) A) and C)

Correct Answer

verifed

verified

A

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

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

Method calls cannot be distinguished by ________.


A) method name
B) return type
C) parameter lists
D) method signature

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

A Java class can have which of the following methods? A. void foo(int a) B. void foo(int a, int b) C.void foo(double a) D. void foo(double a, double b) E. void foo(int b)


A) All of the above.
B) A, B, D, E.
C) A, B, C, D.
D) A, C, D, E.

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

C

Showing 1 - 20 of 36

Related Exams

Show Answer