Assignment 4 Questions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

All it takes for an OR expression to be true is for one of the subexpressions to be true. Select one: True False

True

Enclosing a group of statements inside a set of braces creates Select one: A. a relational operator. B. a conditional statement. C. a block of statements. D. an expression.

a block of statements

Which of the following expressions determines whether the char variable, chrA, is not equal to the letter 'A'? Select one: A. chrA != 'A' B. chrA == 'A' C. chrA.notEquals(A) D. chrA || 'A'

chrA != 'A'

A flag may have the values Select one: A. of any Unicode character. B. of any range of integers. C. defined or undefined. D. true or false.

true or false

When testing for character values, the switch statement does not test for the case of the character. Select one: True False

False

When two strings are compared using the String class's compareTo method, the comparison is not case sensitive. Select one: True False

False

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); Select one: A. 600.0 B. 300.0 C. 400.0 D. The code contains an error and will not compile.

300.0

The if-else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false. Select one: True False

True

Unicode is an international encoding system that is extensive enough to represent all the characters of all the world's alphabets. Select one: True False

True

Select all that apply. Which method of the Random class will return a random number within the range of 0.0 and 1.0? Select one or more: A. nextInt(int n) B. nextLong() C. nextDouble() D. nextFloat()

nextDouble() nextFloat()

Which of the following expressions will determine whether x is less than or equal to y? Select one: A. x => y B. x >= y C. x <= y D. x =< y

x <= y

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%? Select one: A. "000.0%" B. "##0.0%" C. "###.##%" D. "#0.00%"

"##0.0%"

What will be the value of x after the following statements are executed? int x=75; int y=60; if (x>y) x=x-y Select one: A. 135 B. 15 C. 60 D. 75

15

What will be the value of x after the following statements are executed? int x = 10; switch (x) { case 10: x += 15; case 12: x -= 5; break; default: x *= 3; } Select one: A. 20 B. 25 C. 5 D. 30

20

An important style rule that should be used when writing if statements is to write the conditionally executed statement on the line after the if statement. Select one: True False

True

If the expression on the left side of the && operator is false, the expression on the right side will not be checked. Select one: True False

True

When a character is stored in memory, it is actually the ________ that is stored. Select one: A. floating-point value B. letter, symbol, or number C. Unicode number D. ASCII code

Unicode number

A block of code is enclosed in a set of Select one: A. parentheses, () B. braces, { } C. double quotes, " " D. brackets, [ ]

braces, { }

A ________ is a boolean variable that signals when some condition exists in the program. Select one: A. case B. flag C. block D. sentinel

flag

The ________ statement is used to create a decision structure which allows a program to have more than one path of execution. Select one: A. flag B. if C. null D. block

if

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8? Select one: A. "###.#" B. "#0.00%" C. "000.0" D. "###.0"

"000.0"

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 } Select one: A. 0.06 B. 0.0 C. 0.04 D. 0.08

0.0

What will be the value of discountRate after the following statements are executed? double discountRate=0.0; int purchase=100; if (purchase>1000) discountRate=0.05; else if (purchase>750) discountRate=0.03; else if (purchase>500) discountRate=0.01; Select one: A. 0.0 B. 0.03 C. 0.01 D. 0.05

0.0

What will be the value of discountRate after the following statements are executed? double discountRate=0.0; int purchase=1250; char cust = 'N'; if (purchase>1000) if (cust == 'Y') discountRate=0.04; else discountRate=0.03; else discountRate=0.0; Select one: A. 0.04 B. 0.0 C. 0.05 D. 0.03

0.04

What will be the value of bonus after the following statements are executed? int bonus, sales=10000; if (sales<5000) bonus = 200; else if (sa;es <7500) bonus = 750; else if (sales <10000) bonus = 1000 else bonus = 1250; Select one: A. 750 B. 1000 C. 500 D. 1250

1000

What will be displayed after the following statements are executed? int x = 65; int y = 55; if (x >= y) { int ans = x + y; } System.out.println(ans); Select one: A. 10 B. 100 C. 120 D. The code contains an error and will not compile.

120

What will be displayed after the following statements are executed? int y = 10; if (y == 10) { int x = 30; x += y; System.out.println(x); } Select one: A. 20 B. 30 C. 40 D. The code contains an error and will not compile.

40

A random number, created as an object of the Random class, is always an integer. Select one: True False

False

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

False

The DecimalFormat class is part of the Java API so it is automatically available to your programs. Select one: True False

False

The if-else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false. Select one: True False

False

Which of the following statements will create an object from the Random class? Select one: A. Random myNumber = new Random(); B. myNumber = new Random(); C. Random = new randomNumbers(); D. randomNumbers() = new Random();

Random myNumber = new Random();

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; Select one: A. 30 B. 50 C. 80 D. The code contains an error and will not compile.

The code contains an error and will not compile.

Java requires that the boolean expression being tested by an if statement be enclosed in Select one: A. a set of brackets. B. a set of braces. C. a set of double quotes. D. a set of parentheses.

a set of parentheses

What will be the values of ans, x, and y after the following statements are executed? int ans=35, x=50, y=50; if x>=y){ ans=x+10; x -= y; } else{ ans = y+10; y += x; } Select one: A. ans = 45, x = 50, and y = 50 B. ans = 60, x = 0, and y = 50 C. ans = 60, x = 50, and y = 100 D. ans = 45, x = 50, and y = 0

ans = 60, x = 0, and y = 50

Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)? Select one: A. if (temp > 0 || temp < 100) B. if (temp >= 0 || temp <= 100) C. if (temp > 0 && temp < 100) D. if (temp >= 0 && temp <= 100)

if (temp >= 0 && temp <= 100)

Which of the following expressions will generate a random number in the range of 1 through 10? Select one: A. myNumber = randomNumbers.nextInt(10) + 1; B. myNumber = randomNumbers.nextInt(11) - 1; C. myNumber = randomNumbers.nextInt(1) + 10; D. myNumber = randomNumbers.nextInt(10);

myNumber = randomNumbers.nextInt(10) + 1;

________ operators are used to determine whether a specific relationship exists between two values. Select one: A. Logical B. Assignment C. Arithmetic D. Relational

relational

If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal? Select one: A. str1 = str2 B. str1 && str2 C. str1 += str2 D. str1.equals(str2)

str1.equals(str2)

Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2? Select one: A. str1 != str2 B. str1.equalsIgnoreCase(str2) C. str1.equalsInsensitive(str2) D. str1 || str2

str1.equalsIgnoreCase(str2)

In an if-else statement, if the boolean expression is false Select one: A. all the statements or blocks are executed. B. the first statement or block is executed. C. the statement or block following the else is executed. D. no statements or blocks are executed.

the statement or block following the else is executed.

The boolean expression in an if statement must evaluate to Select one: A. degrees or radians. B. positive or negative. C. true or false. D. left or right.

true or false


संबंधित स्टडी सेट्स

GOVT 2306 Texas Government Chapter 8 - Public Opinion and the Media

View Set

Lab Simulation: Cell Structure: Cell Theory and Internal Organelles

View Set

AP Computer Science Principles Chapter 3 Review

View Set

Unit Summary Test V4 C708 Principles of accounting

View Set