btaProgramming Quiz 4

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8? "#0.00%" "###.0" "###.#" "000.0

000.0

________ operators are used to determine whether a specific relationship exists between two values. Arithmetic Logical Assignment Relational

Relational

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

True

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

x <= y

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; 135 15 60 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; } 20 25 5 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. 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. True False

True

A block of code is enclosed in a set of parentheses, ( ) double quotes, " " brackets, [ ] braces, { }

braces

A ________ is a boolean variable that signals when some condition exists in the program. block sentinel flag case

flag

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

if

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%? "#0.00%" "##0.0%" "###.##%" "000.0%"

##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; 0.03 0.01 0.0 0.05

0.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; } 0.06 0.0 0.04 0.08

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.05; else discountRate = 0.04; else if (purchase > 750) if (cust == 'Y') discountRate = 0.04; else discountRate = 0.03; else discountRate = 0.0; 0.03 0.0 0.05 0.04

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 (sales < 7500) bonus = 500; else if (sales < 10000) bonus = 750; else if (sales < 20000) bonus = 1000; else bonus = 1250; 1250 750 1000 500

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); 120 The code contains an error and will not compile. 100 10

120

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); 600.0 400.0 300.0 The code contains an error and will not compile.

300.0

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); } 20 40 30 The code contains an error and will not compile.

40

Which of the following statements will create an object from the Random class? Random myNumber = new Random(); Random = new randomNumbers(); myNumber = new Random(); randomNumbers() = new Random();

Random myNumber = new Random( ) ;

Enclosing a group of statements inside a set of braces creates an expression. a conditional statement. a relational operator. a block of statements.

a block of statements

Java requires that the boolean expression being tested by an if statement be enclosed in a set of double quotes. a set of parentheses. a set of brackets. a set of braces.

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; } ans = 45, x = 50, and y = 50 ans = 60, x = 50, and y = 100 ans = 45, x = 50, and y = 0 ans = 60, x = 0, and y = 50

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

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

chrA !=A

Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)? if (temp >= 0 || temp <= 100) if (temp > 0 || temp < 100) if (temp >= 0 && temp <= 100) 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? myNumber = randomNumbers.nextInt(10); myNumber = randomNumbers.nextInt(10) + 1; myNumber = randomNumbers.nextInt(1) + 10; myNumber = randomNumbers.nextInt(11) - 1;

myNumber = randomNumber.nextInt(10) +1;

If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal? str1 = str2 str1 && str2 str1.equals(str2) str1 += 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? str1 != str2 str1.equalsIgnoreCase(str2) str1.equalsInsensitive(str2) str1 || str2

str1.equalsIgnoreCase(str2)

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; 30 The code contains an error and will not compile. 80 50

the code contains error...

In an if-else statement, if the boolean expression is false no statements or blocks are executed. the first statement or block is executed. all the statements or blocks are executed. the statement or block following the else is executed

the statement or block following the else is executed

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

true

A flag may have the values of any range of integers. of any Unicode character. true or false. defined or undefined.

true or false

The boolean expression in an if statement must evaluate to positive or negative. degrees or radians. true or false. left or right.

true or false

Question 1 1 / 1 pts When a character is stored in memory, it is actually the ________ that is stored. Unicode number letter, symbol, or number ASCII code floating-point value

unicode number


Set pelajaran terkait

Federal Tax Considerations for Life Insurance and Annuities

View Set

How are oxbow lakes formed from meanders?

View Set

MISY 5350 Exam 1 Review - Chapter 2

View Set

Porth's Patho: Renal Disease, Chapter 34

View Set

Chapter 26 ( administration of medication and intravenous therapy)

View Set