Coding Data Basics Test Study Guide

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

which of the following is a shortcut operator that will reduce the value of a variable by 1?

--

what is the result of the following mathematical expression and assignment statement? double midpoint=(1+2)/2;

1.0

what value is stored in the "mysteryMath" variable by the following statement? int mysteryMath=4+3*2;

10

what value is stored in the "score" variable as a result of the following statement? long score=(long)10.5;

10

what value is stored in the "mysteryMath" variable by the following statement? int mysteryMath=(4+3)*2;

14

what value is stored in the "mysteryMath" variable after the following statements are run? int input1=5; int input2=10; int mysteryMath=input2-input1; mysteryMath=mysteryMath+10;

15

what value is stored in the "rounded" variable as a result of the following statement? double exactValue=1.6; int rounded=(int)(exactValue+0.5);

2

what value is held in the "herdingSquirrels" variable after the following statements are run? int herdingSquirrels=2; herdingSquirrels+=5; herdingSquirrels++;

8

what is the purpose of a compound assignment statement?

do some math using the contents of a variable as the left operand, and store the result back in the variable

how would you write the statement "dogs=dogs+2;" in a more compact manner

dogs+=2;

which of the following statements will divide 10.0 by 3.0 and store the result in the "answer" variable?

double answer=10.0/3.0

given the following variable declaration, which of the answers correctly casts the value to store in an "int" variable? float exactPrice=3.50F;

int dollars=(int)exactPrice;

what is wrong with the following code? double frequency=10.0; frequency*=10.0;

nothing is wrong; frequency will hold 100.0 afterward

what is the purpose of the modulus (%) operator?

to return the remainder from an integer division operation

when will java auto-cast one data type to another?

when the cast cannot possibly result in any data loss


Ensembles d'études connexes

Chapter 30: An Introduction to Animals

View Set

Chapter 3 Comparative Advantage and The Gains from Trade

View Set

MRU19.4: THE TRAGEDY OF THE COMMONS

View Set

Chapter 2-Introduction to Scanners

View Set