Filters
Question type

Study Flashcards

Select all that apply. Which method of the Random class will return a random number within the range of 0.0 and 1.0?


A) nextDouble()
B) nextLong()
C) nextFloat()
D) nextInt(int n)

Correct Answer

verifed

verified

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8?


A) "###.#"
B) "###.0"
C) "000.0"
D) "#0.00%"

Correct Answer

verifed

verified

A flag may have the values


A) defined or undefined
B) true or false
C) of any range of integers
D) of any Unicode character

Correct Answer

verifed

verified

A __________ is a boolean variable that signals when some condition exists in the program.


A) sentinel
B) flag
C) block
D) case

Correct Answer

verifed

verified

Which of the following expressions will determine whether x is less than or equal to y?


A) x <= y
B) x => y
C) x >= y
D) x =< y

Correct Answer

verifed

verified

What will be the value of ans after the following statements are executed? int x = 40; Int y = 40; If (x = y) Ans = x + 10;


A) 30
B) 80
C) 50
D) The code contains an error and will not compile.

Correct Answer

verifed

verified

A random number, created as an object of the Random class, is always an integer.

Correct Answer

verifed

verified

What will be the value of discountRate after the following statements are executed? double discountRate; Char custType = 'B'; Switch (custType) { Case 'A': DiscountRate = 0.08; Break; Case 'B': DiscountRate = 0.06; Case 'C': DiscountRate = 0.04; Default: DiscountRate = 0.0; }


A) 0.08
B) 0.06
C) 0.04
D) 0.0

Correct Answer

verifed

verified

Which of the following expressions will generate a random number in the range of 1 through 10?


A) myNumber = randomNumbers.nextInt(10) ;
B) myNumber = randomNumbers.nextInt(1) + 10;
C) myNumber = randomNumbers.nextInt(11) - 1;
D) myNumber = randomNumbers.nextInt(10) + 1;

Correct Answer

verifed

verified

Java requires that the boolean expression being tested by an if statement be enclosed in


A) a set of parentheses
B) a set of braces
C) a set of double quotes
D) a set of brackets

Correct Answer

verifed

verified

Which of the following statements will create an object from the Random class?


A) randomNumbers() = new Random() ;
B) Random myNumber = new Random() ;
C) myNumber = new Random() ;
D) Random = new randomNumbers() ;

Correct Answer

verifed

verified

In a switch statement, if two different values for the CaseExpression would result in the same code being executed, you must have two copies of the code, one after each CaseExpression.

Correct Answer

verifed

verified

When testing for character values, the switch statement does not test for the case of the character.

Correct Answer

verifed

verified

Which of the following expressions determines whether the char variable, chrA, is not equal to the letter 'A'?


A) chrA == 'A'
B) chrA != 'A'
C) chrA || 'A'
D) chrA.notEquals(A)

Correct Answer

verifed

verified

The __________ statement is used to create a decision structure which allows a program to have more than one path of execution.


A) block
B) if
C) null
D) flag

Correct Answer

verifed

verified

All it takes for an AND expression to be true is for one of the subexpressions to be true.

Correct Answer

verifed

verified

Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive) ?


A) if (temp >= 0 && temp <= 100)
B) if (temp > 0 && temp < 100)
C) if (temp >= 0 || temp <= 100)
D) if (temp > 0 || temp < 100)

Correct Answer

verifed

verified

If the expression on the left side of the && operator is false, the expression on the right side will not be checked.

Correct Answer

verifed

verified

The DecimalFormat class is part of the Java API so it is automatically available to your programs.

Correct Answer

verifed

verified

What will be displayed after the following statements are executed? int hours = 30; Double pay, payRate = 10.00; Pay = hours <= 40 ? hours*payRate : hours*payRate*2.0; System.out.println(pay) ;


A) 300.0
B) 600.0
C) 400.0
D) The code contains an error and will not compile.

Correct Answer

verifed

verified

Showing 21 - 40 of 42

Related Exams

Show Answer