CSC200 Ch. 5 Quiz

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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) { ... }

All four methods are overloaded

Which of the following can be an argument to a method?

All of these (constants, variables, and expressions)

The parameter list in the method header and the arguments in the method call must agree in ________.

All of these (number, type, and order)

Which operator can be used in string concatenation?

+=

Which statement below could be used to simulate the outputs of rolling a six-sided die? Suppose randomNumbers is a SecureRandom object.

1 + randomNumbers.nextInt(6);

Which statement creates a random value from the sequence 2, 5, 8, 11 and 14. Suppose randomNumbers is a SecureRandom object.

2 + 3 * randomNumbers.nextInt(5);

A Java class can have which of the following methods?

A, B, C, D (all of them except the one that says void foo(int b))

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

Color

If more method calls occur than can have their activation records stored on the program execution stack, an error known as a ________ occurs.

stack overflow

Information is passed to a method in __________.

the arguments to the method

When an object is concatenated with a String, ____________.

the object's toString method is implicitly called to obtain the String representation of the object

To declare a method as static, place the keyword static before ________ in the method's declaration.

the return type

Math static method random generates a random double value in the range from 0.0 ________.

up to but not including 1.0

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

without creating an instance of the class in which main is declared

Consider the following Java statements: int x = 9; double y = 5.3; result = calculateValue(x, y); Which of the following statements is false?

x and y are parameters.

Which of the following statements is false?

If a method does not return a value, the return-value-type in the method declaration can be omitted.

Which of the following statements describes block scope?

It begins at the identifier's declaration and ends at the terminating right brace (}).

Stacks are known as ________ data structures.

LIFO

Which is a correct static method call of Math class method sqrt?

Math.sqrt(900);

Which of these statements best defines scope?

Scope is the portion of a program that can refer to an entity by its simple name.

Which of the following statements is false?

The Java API consists of import declarations.

Identifiers in Java have ________ and ________ scopes.

class, block

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

classes

Which of the following promotions of primitive types is not allowed to occur?

double to float

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

e

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) ________.

enum

Filled rectangles and filled circles are drawn using Graphics method ________ and ________.

fillRect, fillOval

Which of the following is not a package in the Java API?

java.component

Overloaded methods always have the same ________.

method name

The identifiers in an enumeration ________.

must be unique

In a class containing methods with the same name, the methods are distinguished by ________.

number of arguments and types of arguments

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

parseInt

A well-designed method ________.

performs a single, well-defined task

Which of the following primitive types is never promoted to another primitive type?

both double and boolean

An overloaded method is one that ________.

has the same name as another method, but different parameters (by number, types or order of the types)

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.

randomNumbers.nextInt(2);

Method calls cannot be distinguished by _________.

return type


Kaugnay na mga set ng pag-aaral

International Management Exam #3 (Chapters 8, 9, & 10)

View Set

Organizational Behavior Chapter 8 Smartbook stuff

View Set