Deck 4: Fundamental Data Types

Full screen (f)
exit full mode
Question
Which of the following statements with comments is(are) valid? <strong>Which of the following statements with comments is(are) valid?   </strong> A)Only I B)I and II C)II and III D)Only III <div style=padding-top: 35px>

A)Only I
B)I and II
C)II and III
D)Only III
Use Space or
up arrow
down arrow
to flip the card.
Question
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The average variable is never initialized. B)The data type for the average variable is not specified. C)The average variable is never assigned a value. D)The average variable is assigned a non-numeric value. <div style=padding-top: 35px>

A)The average variable is never initialized.
B)The data type for the average variable is not specified.
C)The average variable is never assigned a value.
D)The average variable is assigned a non-numeric value.
Question
Which of the following guidelines will make code more explanatory for others?

A)Use shorter statements and shorter variable names in source code.
B)Add comments to source code.
C)Avoid usage of complex calculations in source code.
D)Always enclose the statements in curly braces in source code.
Question
Which one of the following refers to a number constant that appears in code without explanation?

A)Constant
B)Variable
C)Magic number
D)String literal
Question
What is wrong with the following code?
int count = 2000 * 3000 * 4000;

A)Wrong data type
B)Variable is undefined
C)Integer overflow
D)Illegal expression
Question
Which one of the following variables is assigned with valid literals?

A) int salary =0;
salary = 5000.50;
B) int salary 1=0;
salary 1=1.2E6;
C) double salary 2=0;
salary 2=2.96E-2;
D) long salary 3=0;
salary 3=1E-6;
Question
Which one of the following statements defines a constant with the value 123?

A) final int MY_CONST = 1 2 3 ;
B) const int MY_CONST =123;
C) final int
MY_CONST =0 ;
MY CONST =123 ;
D) static int MY_CONST =123;
Question
What is the output of this code snippet? <strong>What is the output of this code snippet?   </strong> A)2424 B)2425 C)2428 D)2528 <div style=padding-top: 35px>

A)2424
B)2425
C)2428
D)2528
Question
Which of the following options declares a float variable?

A)Float age;
B)flt age;
C)float age;
D)age: float;
Question
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The code snippet uses an uninitialized variable. B)The code snippet uses an undeclared variable. C)The code snippet attempts to assign a decimal value to an integer variable. D)The code snippet attempts to add a number to a string variable. <div style=padding-top: 35px>

A)The code snippet uses an uninitialized variable.
B)The code snippet uses an undeclared variable.
C)The code snippet attempts to assign a decimal value to an integer variable.
D)The code snippet attempts to add a number to a string variable.
Question
Which option represents the best choice for a variable name to represent the average grade of students on an exam?

A)averageGrade
B)$averageGrade
C)avg
D)AveGd
Question
What is the output of this code snippet? double average;
int grade1 =87;
int grade2 =94;
/ / system. out. print("The average is " +(grade1+grade2) / 2.0) ;
System.out.print("The average is " + average);

A) Compile-time error
B) The average is 91.5
C) The average is 91.5
The average is 91.5
D) The average is 91.5
The average is 0.0
Question
What is the result of the following code snippet? <strong>What is the result of the following code snippet?   </strong> A)0 B)3.14 C)6.28 D)compile-time error <div style=padding-top: 35px>

A)0
B)3.14
C)6.28
D)compile-time error
Question
What will be the value stored in the variable x after the execution of the following code snippet? <strong>What will be the value stored in the variable x after the execution of the following code snippet?   </strong> A)1 B)2 C)4 D)The code has a syntax error <div style=padding-top: 35px>

A)1
B)2
C)4
D)The code has a syntax error
Question
The assignment operator

A)denotes mathematical equality
B)places a new value into a variable
C)means the same as the equals sign used in algebra
D)makes it illegal to write a statement like sum = sum + 4;
Question
Which statement about number literals in Java is false?

A)Numbers in exponential notation always have type double
B)Zero is an integer
C)Integers must be positive
D)An integer with fractional part of .0 has type double.
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)The initial value of the counter is 0 B)The initial value of the counter is 1 C)The code will not compile D)The initial value of the counter is <div style=padding-top: 35px>

A)The initial value of the counter is 0
B)The initial value of the counter is 1
C)The code will not compile
D)The initial value of the counter is
Question
Which of the following statements about constants in Java are true?
I.Although not required, constants are commonly named using uppercase letters
II.Only integer values can appear as constants
III.A variable can be defined with an initial value, but the reserved word final prevents it from being changed
IV.A named constant makes computations that use it clearer

A)I, II, III
B)II, III, IV
C)I, III, IV
D)I, II, IV
Question
Which statement is true?

A)Variables cannot be assigned and declared in the same statement
B)Variable names must contain at least one dollar sign
C)Variable names can be no more than 8 characters long
D)It is incorrect to initialize a string variable with a number
Question
Which of the following statements about constants is correct?

A)Constants are written using capital letters because the compiler ignores constants declared in small letters.
B)The data stored inside a constant can be changed using an assignment statement.
C)You can make a variable constant by using the final reserved word when declaring it.
D)Constant variables can only be changed through the Math library.
Question
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The price variable is never initialized. B)The data type for the price variable is not specified. C)The price variable is never assigned a value. D)The price variable is assigned a decimal value. <div style=padding-top: 35px>

A)The price variable is never initialized.
B)The data type for the price variable is not specified.
C)The price variable is never assigned a value.
D)The price variable is assigned a decimal value.
Question
In an airline reservation system, the number of available seats in an airplane is required.Which data type should be used to store this value?

A)double
B)float
C)int
D)long
Question
What is the value of the following expression?
-18 % 5

A)-2
B)-3
C)2
D)3
Question
What is the meaning of x = 0; in Java?

A)It checks whether x equals 0.
B)It sets the variable x to zero.
C)It defines a variable named x and initializes it with 0.
D)It is a syntax error because x is not always 0.
Question
Which of the following options defines an integer variable?

A)char age;
B)integer age;
C)int age;
D)age: int;
Question
Consider the following Java variable names:
I.1stInstance
II.basicInt%
III.empName_
IV.addressLine1
V.DISCOUNT
Which of the following options is correct?

A)Only IV is a valid Java variable name.
B)Only I and IV are valid Java variable names.
C)Only I, IV, and V are valid Java variable names.
D)Only III, IV, and V are valid Java variable names.
Question
What is the value of the following expression?
2 + 3 + 5 / 2

A)5
B)6
C)7
D)7.5
Question
What is the result of the following code snippet? <strong>What is the result of the following code snippet?   </strong> A)0 B)1 C)2 D)Does not compile <div style=padding-top: 35px>

A)0
B)1
C)2
D)Does not compile
Question
Which statements about numeric types in Java are true?
I.There is more than one integer type
II.The data type float uses twice the storage of double
III.The numeric range of the Java integer type is related to powers of two

A)I, II
B)I, III
C)II, III
D)I, II, III
Question
Which statement is true about variable names in Java?

A)They can contain the percent sign (%)
B)They can contain an underscore symbol ("_")
C)They can contain spaces
D)They must make sense as a word
Question
Which one of the following types of statements is an instruction to set the value of a variable?

A)Update
B)Declaration
C)Assignment
D)Initialization
Question
Which of the following statements is correct about constants?

A)Constants are written using uppercase letters because the compiler ignores constants declared in lowercase letters.
B)The data stored inside a final variable can be changed using an assignment statement.
C)You can make a variable constant by using the constant reserved word while declaring the variable.
D)Variables defined using final make a code snippet more readable and easier to maintain.
Question
The typical ranges for integers may seem strange but are derived from

A)Base 10 floating-point precision
B)Field requirements for typical usage and limits
C)Overflows
D)Powers of two because of base 2 representation within the computer
Question
Why is the double type not appropriate for financial calculations?

A)Roundoff errors occur when an exact representation of a floating point number is not possible.
B)The range is too small.
C)The calculations are too slow.
D)There are too few significant digits.
Question
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The code snippet uses a variable that has not yet been initialized. B)The code snippet uses a variable that has not been declared. C)The code snippet attempts to assign a decimal value to an integer variable. D)The code snippet attempts to assign an integer value to a decimal variable. <div style=padding-top: 35px>

A)The code snippet uses a variable that has not yet been initialized.
B)The code snippet uses a variable that has not been declared.
C)The code snippet attempts to assign a decimal value to an integer variable.
D)The code snippet attempts to assign an integer value to a decimal variable.
Question
What is the upper limit on the size of an integer represented by the BigInteger object in Java?

A)32,767
B)2,147,483,647
C)9,223,372,036,854,775,807
D)Essentially no limit
Question
Which one of the following is a correct method for defining and initializing an integer variable with name value?

A)int value = 30;
B)Int value = 30;
C)int value = .30;
D)Int value = .30;
Question
Which one of the following is an assignment statement?

A)int a = 20;
B)a = 20;
C)assign a = 20;
D)assign 20 to a;
Question
Which is a legal number literal of type int in Java?

A)100,000
B)100.000
C)100_000
D)100000L
Question
Which one of the following reserved words is used in Java to represent a value without a fractional part?

A)integer
B)int
C)Int
D)Float
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)2 B)3 C)4 D)No output due to syntax error <div style=padding-top: 35px>

A)2
B)3
C)4
D)No output due to syntax error
Question
Which is a correct representation of the given mathematical expression in Java? <strong>Which is a correct representation of the given mathematical expression in Java?   </strong> A)a + b % 2 B)a + b / 2 C)a + (b / 2) D)(a + b) / 2 <div style=padding-top: 35px>

A)a + b % 2
B)a + b / 2
C)a + (b / 2)
D)(a + b) / 2
Question
What is the value of Math.abs(-2)?

A)-2
B)0
C)2
D)4
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)25.0 B)337.0 C)7.0 D)19.0 <div style=padding-top: 35px>

A)25.0
B)337.0
C)7.0
D)19.0
Question
What is the value of the value variable at the end of the given code snippet? <strong>What is the value of the value variable at the end of the given code snippet?   </strong> A)-2 B)0 C)2 D)4 <div style=padding-top: 35px>

A)-2
B)0
C)2
D)4
Question
What happens to the fractional part when a division is performed on two integer variables?

A)The fractional part is rounded off to the nearest integer value.
B)The fractional part is discarded.
C)Two integers cannot be used in division; at least one of the operands should be a floating-point number.
D)Instead of using an integer division, you should use the modulus operator to perform floating-point division.
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)0 B)4 C)20 D)There will be no output due to a run-time error. <div style=padding-top: 35px>

A)0
B)4
C)20
D)There will be no output due to a run-time error.
Question
Which is the Java equivalent of the following mathematical expression? <strong>Which is the Java equivalent of the following mathematical expression?   </strong> A)c = Math.sqrt(a * 2 + b * 2); B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2); C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); D)c = Math.sqrt(Math.pow(a, 2)) + Math.sqrt(Math.pow(b, 2)); <div style=padding-top: 35px>

A)c = Math.sqrt(a * 2 + b * 2);
B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
D)c = Math.sqrt(Math.pow(a, 2)) + Math.sqrt(Math.pow(b, 2));
Question
What is the value of Math.pow(3, 2)?

A)6.0
B)9.0
C)8.0
D)5.0
Question
What is the value of the following expression?
1 % 12

A)1
B)0
C)-11
D)This is an error because 12 is greater than 1
Question
What is the result of the following expression?
double d = 2.5 + 4 * -1.5 - (2.5 + 4) * -1.5;

A)24.375
B)6.25
C)12.375
D)6
Question
Consider the following division statements:
I.22 / 7
II.22.0 / 7
III.22 / 7.0
Which of the following is correct?

A)All three statements will return an integer value.
B)Only I will return an integer value.
C)Only I, II will return an integer value.
D)Only I and III will return an integer value.
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)25 B)50 C)49 D)26 <div style=padding-top: 35px>

A)25
B)50
C)49
D)26
Question
Which one of the following operators computes the remainder of an integer division?

A)/
B)%
C)\
D)!
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)25.0 B)34 C)7.0 D)14 <div style=padding-top: 35px>

A)25.0
B)34
C)7.0
D)14
Question
Which is the Java equivalent of the following mathematical expression? <strong>Which is the Java equivalent of the following mathematical expression?   </strong> A)c = 2 * Math.PI * radius * 2; B)c = 2 * Math.PI * Math.pow(2, radius); C)c = 2 * Math.PI * Math.pow(radius, 2); D)c = 2 * Math.PI * radius; <div style=padding-top: 35px>

A)c = 2 * Math.PI * radius * 2;
B)c = 2 * Math.PI * Math.pow(2, radius);
C)c = 2 * Math.PI * Math.pow(radius, 2);
D)c = 2 * Math.PI * radius;
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)36 B)36.525 C)37 D)No output because the code snippet generates compilation errors <div style=padding-top: 35px>

A)36
B)36.525
C)37
D)No output because the code snippet generates compilation errors
Question
Which one of the following statements gives the absolute value of the floating-point number x = -25.50?

A)abs(x);
B)Math.abs(x);
C)x.abs();
D)x.absolute();
Question
What will be the value of the variables a and b after the given set of assignments? <strong>What will be the value of the variables a and b after the given set of assignments?   </strong> A)a = 15, b = 16 B)a = 16, b = 16 C)a = 16, b = 15 D)a = 15, b = 15 <div style=padding-top: 35px>

A)a = 15, b = 16
B)a = 16, b = 16
C)a = 16, b = 15
D)a = 15, b = 15
Question
What are the values of num1 and num2 after this snippet executes? <strong>What are the values of num1 and num2 after this snippet executes?   </strong> A)num1 = 4.20 and num2 = 42.0 B)num1 = 4.20 and num2 = 47.0 C)num1 = 42.0 and num2 = 42.0 D)num1 = 42.0 and num2 = 47.0 <div style=padding-top: 35px>

A)num1 = 4.20 and num2 = 42.0
B)num1 = 4.20 and num2 = 47.0
C)num1 = 42.0 and num2 = 42.0
D)num1 = 42.0 and num2 = 47.0
Question
Given the definition final double PI = 3.14159; which of the following is the Java equivalent of the mathematical expression

<strong>Given the definition final double PI = 3.14159; which of the following is the Java equivalent of the mathematical expression   </strong> A)c = PI * (radius * 2); B)c = PI * Math.pow(2, radius); C)c = PI * Math.pow(radius, 2); D)c = Math.pow(PI * radius, 2); <div style=padding-top: 35px>

A)c = PI * (radius * 2);
B)c = PI * Math.pow(2, radius);
C)c = PI * Math.pow(radius, 2);
D)c = Math.pow(PI * radius, 2);
Question
When you purchase donuts, they come in boxes of 12, so 24 donuts take 2 boxes.All donuts need to be in a box, so if you buy 13 donuts, you'll get 2 boxes with 12 in the first box and 1 in the second.If the integer variable numberOfDonuts contains the positive number of donuts purchased, which of the following will correctly give the number of boxes needed?

A)int numberOfBoxes = (numberOfDonuts + 11) / 12;
B)int numberOfBoxes = numberOfDonuts / 12;
C)int numberOfBoxes = 1 + numberOfDonuts / 12;
D)int numberOfBoxes = numberOfDonuts / 12 + numberOfDonuts % 12;
Question
Which is the Java equivalent of the following mathematical expression? <strong>Which is the Java equivalent of the following mathematical expression?   </strong> A)c = (Math.sqrt(a) + Math.sqrt(b)) * 2; B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2); C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); D)c = Math.pow((Math.sqrt(a) + Math.sqrt(b)), 2); <div style=padding-top: 35px>

A)c = (Math.sqrt(a) + Math.sqrt(b)) * 2;
B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
D)c = Math.pow((Math.sqrt(a) + Math.sqrt(b)), 2);
Question
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)0 B)4 C)10 D)250 <div style=padding-top: 35px>

A)0
B)4
C)10
D)250
Question
Assume the following variables have been declared as shown and given values elsewhere:
double a, b, c;
The discriminant of a quadratic equation is defined to be: <strong>Assume the following variables have been declared as shown and given values elsewhere: double a, b, c; The discriminant of a quadratic equation is defined to be:   Which of the following statements will assign the correct value to discriminant? </strong> A)double discriminant = Math.sqrt(b * b - 4 * a * c); B)double discriminant = Math.sqrt(b * b) - 4 * a * c; C)double discriminant = Math.sqrt(b * b) - Math.sqrt(4 * a * c); D)double discriminant = Math.sqrt(b2 - 4ac) <div style=padding-top: 35px> Which of the following statements will assign the correct value to discriminant?

A)double discriminant = Math.sqrt(b * b - 4 * a * c);
B)double discriminant = Math.sqrt(b * b) - 4 * a * c;
C)double discriminant = Math.sqrt(b * b) - Math.sqrt(4 * a * c);
D)double discriminant = Math.sqrt(b2 - 4ac)
Question
Assuming that the user inputs a value of 25000 for the pay and 10 for the bonus rate in the following code snippet, what is the output? <strong>Assuming that the user inputs a value of 25000 for the pay and 10 for the bonus rate in the following code snippet, what is the output?   </strong> A)The new pay is 25000.0 B)The new pay is 25100.0 C)The new pay is 27500.0 D)The new pay is 30000.0 <div style=padding-top: 35px>

A)The new pay is 25000.0
B)The new pay is 25100.0
C)The new pay is 27500.0
D)The new pay is 30000.0
Question
Assuming that the user inputs a value of 25 for the price and 10 for the discount rate in the following code snippet, what is the output? <strong>Assuming that the user inputs a value of 25 for the price and 10 for the discount rate in the following code snippet, what is the output?   </strong> A)The new price is 25.0 B)The new price is 15.0 C)The new price is 22.5 D)The new price is 20.0 <div style=padding-top: 35px>

A)The new price is 25.0
B)The new price is 15.0
C)The new price is 22.5
D)The new price is 20.0
Question
What is the value of the var variable at the end of the given code snippet? <strong>What is the value of the var variable at the end of the given code snippet?   </strong> A)0 B)1 C)30 D)31 <div style=padding-top: 35px>

A)0
B)1
C)30
D)31
Question
What is the difference between the result of the following two Java statements?
I.int cents = (int)(100 * price + 0.5);
II.int cents = (100 * price + 0.5);

A)Statement I causes truncation, but II does not
B)Statement II causes truncation, but I does not
C)Statement I compiles, but II does not
D)Statement II compiles, but I does not
Question
Which of the following statements will assign the largest value of three integer variables a, b, and c to the integer variable maximum?

A) maximum = Math.max (a, b, c);
B) maximum=Math.max (a, b);
maximum= Math.(b, c);
maximum=Math.max (a, c);
C) maximum = Math.max (a, b);
maximum = Math. max (maximum, c);
D) maximum = Math.max (a, b)+ Math.max (b, c)+ Math.max (a, c);
Question
One way to avoid round-off errors is to use:

A)Math.sqrt()
B)Math.pow()
C)Math.round()
D)Math.truncate()
Question
What is the output of the following statement sequence? <strong>What is the output of the following statement sequence?   </strong> A)4 B)Compile-time error C)Run-time error D)16 <div style=padding-top: 35px>

A)4
B)Compile-time error
C)Run-time error
D)16
Question
What will be the value of the variables x and y after the given set of assignments? <strong>What will be the value of the variables x and y after the given set of assignments?   </strong> A)x = 40, y = 20 B)x = 20, y = 10 C)x = 10, y = 20 D)x = 20, y = 20 <div style=padding-top: 35px>

A)x = 40, y = 20
B)x = 20, y = 10
C)x = 10, y = 20
D)x = 20, y = 20
Question
What is the value of Math.pow(2, 3)?

A)5.0
B)6.0
C)8.0
D)9.0
Question
Which is the mathematical equivalent of the following Java expression? <strong>Which is the mathematical equivalent of the following Java expression?  </strong> A) h=4ab-2b/ c B) h=(4ab-2b) / c C) h=4 ab-b<sup>2</sup> / c D) h=4ab-b<sup>2</sup> / c <div style=padding-top: 35px>

A) h=4ab-2b/ c
B) h=(4ab-2b) / c
C) h=4 ab-b2 / c
D) h=4ab-b2 / c
Question
Which of the following is the Java equivalent of the following mathematical expression? <strong>Which of the following is the Java equivalent of the following mathematical expression?   </strong> A)p = 2 * Math.PI * (radius * 3); B)p = Math.PI * Math.pow(3,radius); C)p = 2 * Math.PI * Math.pow(radius, 3); D)p = 2 * Math.pow(Math.PI * radius, 3); <div style=padding-top: 35px>

A)p = 2 * Math.PI * (radius * 3);
B)p = Math.PI * Math.pow(3,radius);
C)p = 2 * Math.PI * Math.pow(radius, 3);
D)p = 2 * Math.pow(Math.PI * radius, 3);
Question
What is result of evaluating the following expression? <strong>What is result of evaluating the following expression?   </strong> A)2 B)7 C)2.5 D)3 <div style=padding-top: 35px>

A)2
B)7
C)2.5
D)3
Question
What is the value of the following expression?
3 * 5 / 2 * 5

A)1.5
B)30
C)35
D)37.5
Question
A student's class average can be computed by dividing the number of marks they have earned by the number of marks possible.Assume the following variables have been declared as shown and given values elsewhere:
int marksEarned, marksPossible;
double classPercentage;
Which of the following statements will assign the correct percentage average to classPercentage? For example, if marksEarned is 725 and marksPossible is 1000, classPercentage should be assigned the value 72.5.

A)classPercentage = marksEarned / marksPossible * 100.0;
B)classPercentage = 100 * marksEarned / marksPossible;
C)classPercentage = (100.0 * marksEarned) / marksPossible;
D)classPercentage = (100.0 + marksEarned) / marksPossible;
Question
Which is a correct representation of the given mathematical expression in Java? <strong>Which is a correct representation of the given mathematical expression in Java?   </strong> A)a - b / 2 % 2 B)a - b / 2 C)a - (b / 2) / 2 D)(a - b / 2) / 2 <div style=padding-top: 35px>

A)a - b / 2 % 2
B)a - b / 2
C)a - (b / 2) / 2
D)(a - b / 2) / 2
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/124
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 4: Fundamental Data Types
1
Which of the following statements with comments is(are) valid? <strong>Which of the following statements with comments is(are) valid?   </strong> A)Only I B)I and II C)II and III D)Only III

A)Only I
B)I and II
C)II and III
D)Only III
II and III
2
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The average variable is never initialized. B)The data type for the average variable is not specified. C)The average variable is never assigned a value. D)The average variable is assigned a non-numeric value.

A)The average variable is never initialized.
B)The data type for the average variable is not specified.
C)The average variable is never assigned a value.
D)The average variable is assigned a non-numeric value.
The average variable is assigned a non-numeric value.
3
Which of the following guidelines will make code more explanatory for others?

A)Use shorter statements and shorter variable names in source code.
B)Add comments to source code.
C)Avoid usage of complex calculations in source code.
D)Always enclose the statements in curly braces in source code.
Add comments to source code.
4
Which one of the following refers to a number constant that appears in code without explanation?

A)Constant
B)Variable
C)Magic number
D)String literal
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
5
What is wrong with the following code?
int count = 2000 * 3000 * 4000;

A)Wrong data type
B)Variable is undefined
C)Integer overflow
D)Illegal expression
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
6
Which one of the following variables is assigned with valid literals?

A) int salary =0;
salary = 5000.50;
B) int salary 1=0;
salary 1=1.2E6;
C) double salary 2=0;
salary 2=2.96E-2;
D) long salary 3=0;
salary 3=1E-6;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
7
Which one of the following statements defines a constant with the value 123?

A) final int MY_CONST = 1 2 3 ;
B) const int MY_CONST =123;
C) final int
MY_CONST =0 ;
MY CONST =123 ;
D) static int MY_CONST =123;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
8
What is the output of this code snippet? <strong>What is the output of this code snippet?   </strong> A)2424 B)2425 C)2428 D)2528

A)2424
B)2425
C)2428
D)2528
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following options declares a float variable?

A)Float age;
B)flt age;
C)float age;
D)age: float;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
10
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The code snippet uses an uninitialized variable. B)The code snippet uses an undeclared variable. C)The code snippet attempts to assign a decimal value to an integer variable. D)The code snippet attempts to add a number to a string variable.

A)The code snippet uses an uninitialized variable.
B)The code snippet uses an undeclared variable.
C)The code snippet attempts to assign a decimal value to an integer variable.
D)The code snippet attempts to add a number to a string variable.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
11
Which option represents the best choice for a variable name to represent the average grade of students on an exam?

A)averageGrade
B)$averageGrade
C)avg
D)AveGd
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
12
What is the output of this code snippet? double average;
int grade1 =87;
int grade2 =94;
/ / system. out. print("The average is " +(grade1+grade2) / 2.0) ;
System.out.print("The average is " + average);

A) Compile-time error
B) The average is 91.5
C) The average is 91.5
The average is 91.5
D) The average is 91.5
The average is 0.0
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
13
What is the result of the following code snippet? <strong>What is the result of the following code snippet?   </strong> A)0 B)3.14 C)6.28 D)compile-time error

A)0
B)3.14
C)6.28
D)compile-time error
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
14
What will be the value stored in the variable x after the execution of the following code snippet? <strong>What will be the value stored in the variable x after the execution of the following code snippet?   </strong> A)1 B)2 C)4 D)The code has a syntax error

A)1
B)2
C)4
D)The code has a syntax error
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
15
The assignment operator

A)denotes mathematical equality
B)places a new value into a variable
C)means the same as the equals sign used in algebra
D)makes it illegal to write a statement like sum = sum + 4;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
16
Which statement about number literals in Java is false?

A)Numbers in exponential notation always have type double
B)Zero is an integer
C)Integers must be positive
D)An integer with fractional part of .0 has type double.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
17
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)The initial value of the counter is 0 B)The initial value of the counter is 1 C)The code will not compile D)The initial value of the counter is

A)The initial value of the counter is 0
B)The initial value of the counter is 1
C)The code will not compile
D)The initial value of the counter is
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following statements about constants in Java are true?
I.Although not required, constants are commonly named using uppercase letters
II.Only integer values can appear as constants
III.A variable can be defined with an initial value, but the reserved word final prevents it from being changed
IV.A named constant makes computations that use it clearer

A)I, II, III
B)II, III, IV
C)I, III, IV
D)I, II, IV
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
19
Which statement is true?

A)Variables cannot be assigned and declared in the same statement
B)Variable names must contain at least one dollar sign
C)Variable names can be no more than 8 characters long
D)It is incorrect to initialize a string variable with a number
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following statements about constants is correct?

A)Constants are written using capital letters because the compiler ignores constants declared in small letters.
B)The data stored inside a constant can be changed using an assignment statement.
C)You can make a variable constant by using the final reserved word when declaring it.
D)Constant variables can only be changed through the Math library.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
21
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The price variable is never initialized. B)The data type for the price variable is not specified. C)The price variable is never assigned a value. D)The price variable is assigned a decimal value.

A)The price variable is never initialized.
B)The data type for the price variable is not specified.
C)The price variable is never assigned a value.
D)The price variable is assigned a decimal value.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
22
In an airline reservation system, the number of available seats in an airplane is required.Which data type should be used to store this value?

A)double
B)float
C)int
D)long
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
23
What is the value of the following expression?
-18 % 5

A)-2
B)-3
C)2
D)3
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
24
What is the meaning of x = 0; in Java?

A)It checks whether x equals 0.
B)It sets the variable x to zero.
C)It defines a variable named x and initializes it with 0.
D)It is a syntax error because x is not always 0.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following options defines an integer variable?

A)char age;
B)integer age;
C)int age;
D)age: int;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
26
Consider the following Java variable names:
I.1stInstance
II.basicInt%
III.empName_
IV.addressLine1
V.DISCOUNT
Which of the following options is correct?

A)Only IV is a valid Java variable name.
B)Only I and IV are valid Java variable names.
C)Only I, IV, and V are valid Java variable names.
D)Only III, IV, and V are valid Java variable names.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
27
What is the value of the following expression?
2 + 3 + 5 / 2

A)5
B)6
C)7
D)7.5
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
28
What is the result of the following code snippet? <strong>What is the result of the following code snippet?   </strong> A)0 B)1 C)2 D)Does not compile

A)0
B)1
C)2
D)Does not compile
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
29
Which statements about numeric types in Java are true?
I.There is more than one integer type
II.The data type float uses twice the storage of double
III.The numeric range of the Java integer type is related to powers of two

A)I, II
B)I, III
C)II, III
D)I, II, III
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
30
Which statement is true about variable names in Java?

A)They can contain the percent sign (%)
B)They can contain an underscore symbol ("_")
C)They can contain spaces
D)They must make sense as a word
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
31
Which one of the following types of statements is an instruction to set the value of a variable?

A)Update
B)Declaration
C)Assignment
D)Initialization
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following statements is correct about constants?

A)Constants are written using uppercase letters because the compiler ignores constants declared in lowercase letters.
B)The data stored inside a final variable can be changed using an assignment statement.
C)You can make a variable constant by using the constant reserved word while declaring the variable.
D)Variables defined using final make a code snippet more readable and easier to maintain.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
33
The typical ranges for integers may seem strange but are derived from

A)Base 10 floating-point precision
B)Field requirements for typical usage and limits
C)Overflows
D)Powers of two because of base 2 representation within the computer
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
34
Why is the double type not appropriate for financial calculations?

A)Roundoff errors occur when an exact representation of a floating point number is not possible.
B)The range is too small.
C)The calculations are too slow.
D)There are too few significant digits.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
35
What is wrong with the following code snippet? <strong>What is wrong with the following code snippet?   </strong> A)The code snippet uses a variable that has not yet been initialized. B)The code snippet uses a variable that has not been declared. C)The code snippet attempts to assign a decimal value to an integer variable. D)The code snippet attempts to assign an integer value to a decimal variable.

A)The code snippet uses a variable that has not yet been initialized.
B)The code snippet uses a variable that has not been declared.
C)The code snippet attempts to assign a decimal value to an integer variable.
D)The code snippet attempts to assign an integer value to a decimal variable.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
36
What is the upper limit on the size of an integer represented by the BigInteger object in Java?

A)32,767
B)2,147,483,647
C)9,223,372,036,854,775,807
D)Essentially no limit
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
37
Which one of the following is a correct method for defining and initializing an integer variable with name value?

A)int value = 30;
B)Int value = 30;
C)int value = .30;
D)Int value = .30;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
38
Which one of the following is an assignment statement?

A)int a = 20;
B)a = 20;
C)assign a = 20;
D)assign 20 to a;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
39
Which is a legal number literal of type int in Java?

A)100,000
B)100.000
C)100_000
D)100000L
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
40
Which one of the following reserved words is used in Java to represent a value without a fractional part?

A)integer
B)int
C)Int
D)Float
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
41
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)2 B)3 C)4 D)No output due to syntax error

A)2
B)3
C)4
D)No output due to syntax error
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
42
Which is a correct representation of the given mathematical expression in Java? <strong>Which is a correct representation of the given mathematical expression in Java?   </strong> A)a + b % 2 B)a + b / 2 C)a + (b / 2) D)(a + b) / 2

A)a + b % 2
B)a + b / 2
C)a + (b / 2)
D)(a + b) / 2
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
43
What is the value of Math.abs(-2)?

A)-2
B)0
C)2
D)4
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
44
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)25.0 B)337.0 C)7.0 D)19.0

A)25.0
B)337.0
C)7.0
D)19.0
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
45
What is the value of the value variable at the end of the given code snippet? <strong>What is the value of the value variable at the end of the given code snippet?   </strong> A)-2 B)0 C)2 D)4

A)-2
B)0
C)2
D)4
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
46
What happens to the fractional part when a division is performed on two integer variables?

A)The fractional part is rounded off to the nearest integer value.
B)The fractional part is discarded.
C)Two integers cannot be used in division; at least one of the operands should be a floating-point number.
D)Instead of using an integer division, you should use the modulus operator to perform floating-point division.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
47
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)0 B)4 C)20 D)There will be no output due to a run-time error.

A)0
B)4
C)20
D)There will be no output due to a run-time error.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
48
Which is the Java equivalent of the following mathematical expression? <strong>Which is the Java equivalent of the following mathematical expression?   </strong> A)c = Math.sqrt(a * 2 + b * 2); B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2); C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); D)c = Math.sqrt(Math.pow(a, 2)) + Math.sqrt(Math.pow(b, 2));

A)c = Math.sqrt(a * 2 + b * 2);
B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
D)c = Math.sqrt(Math.pow(a, 2)) + Math.sqrt(Math.pow(b, 2));
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
49
What is the value of Math.pow(3, 2)?

A)6.0
B)9.0
C)8.0
D)5.0
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
50
What is the value of the following expression?
1 % 12

A)1
B)0
C)-11
D)This is an error because 12 is greater than 1
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
51
What is the result of the following expression?
double d = 2.5 + 4 * -1.5 - (2.5 + 4) * -1.5;

A)24.375
B)6.25
C)12.375
D)6
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
52
Consider the following division statements:
I.22 / 7
II.22.0 / 7
III.22 / 7.0
Which of the following is correct?

A)All three statements will return an integer value.
B)Only I will return an integer value.
C)Only I, II will return an integer value.
D)Only I and III will return an integer value.
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
53
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)25 B)50 C)49 D)26

A)25
B)50
C)49
D)26
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
54
Which one of the following operators computes the remainder of an integer division?

A)/
B)%
C)\
D)!
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
55
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)25.0 B)34 C)7.0 D)14

A)25.0
B)34
C)7.0
D)14
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
56
Which is the Java equivalent of the following mathematical expression? <strong>Which is the Java equivalent of the following mathematical expression?   </strong> A)c = 2 * Math.PI * radius * 2; B)c = 2 * Math.PI * Math.pow(2, radius); C)c = 2 * Math.PI * Math.pow(radius, 2); D)c = 2 * Math.PI * radius;

A)c = 2 * Math.PI * radius * 2;
B)c = 2 * Math.PI * Math.pow(2, radius);
C)c = 2 * Math.PI * Math.pow(radius, 2);
D)c = 2 * Math.PI * radius;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
57
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)36 B)36.525 C)37 D)No output because the code snippet generates compilation errors

A)36
B)36.525
C)37
D)No output because the code snippet generates compilation errors
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
58
Which one of the following statements gives the absolute value of the floating-point number x = -25.50?

A)abs(x);
B)Math.abs(x);
C)x.abs();
D)x.absolute();
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
59
What will be the value of the variables a and b after the given set of assignments? <strong>What will be the value of the variables a and b after the given set of assignments?   </strong> A)a = 15, b = 16 B)a = 16, b = 16 C)a = 16, b = 15 D)a = 15, b = 15

A)a = 15, b = 16
B)a = 16, b = 16
C)a = 16, b = 15
D)a = 15, b = 15
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
60
What are the values of num1 and num2 after this snippet executes? <strong>What are the values of num1 and num2 after this snippet executes?   </strong> A)num1 = 4.20 and num2 = 42.0 B)num1 = 4.20 and num2 = 47.0 C)num1 = 42.0 and num2 = 42.0 D)num1 = 42.0 and num2 = 47.0

A)num1 = 4.20 and num2 = 42.0
B)num1 = 4.20 and num2 = 47.0
C)num1 = 42.0 and num2 = 42.0
D)num1 = 42.0 and num2 = 47.0
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
61
Given the definition final double PI = 3.14159; which of the following is the Java equivalent of the mathematical expression

<strong>Given the definition final double PI = 3.14159; which of the following is the Java equivalent of the mathematical expression   </strong> A)c = PI * (radius * 2); B)c = PI * Math.pow(2, radius); C)c = PI * Math.pow(radius, 2); D)c = Math.pow(PI * radius, 2);

A)c = PI * (radius * 2);
B)c = PI * Math.pow(2, radius);
C)c = PI * Math.pow(radius, 2);
D)c = Math.pow(PI * radius, 2);
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
62
When you purchase donuts, they come in boxes of 12, so 24 donuts take 2 boxes.All donuts need to be in a box, so if you buy 13 donuts, you'll get 2 boxes with 12 in the first box and 1 in the second.If the integer variable numberOfDonuts contains the positive number of donuts purchased, which of the following will correctly give the number of boxes needed?

A)int numberOfBoxes = (numberOfDonuts + 11) / 12;
B)int numberOfBoxes = numberOfDonuts / 12;
C)int numberOfBoxes = 1 + numberOfDonuts / 12;
D)int numberOfBoxes = numberOfDonuts / 12 + numberOfDonuts % 12;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
63
Which is the Java equivalent of the following mathematical expression? <strong>Which is the Java equivalent of the following mathematical expression?   </strong> A)c = (Math.sqrt(a) + Math.sqrt(b)) * 2; B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2); C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); D)c = Math.pow((Math.sqrt(a) + Math.sqrt(b)), 2);

A)c = (Math.sqrt(a) + Math.sqrt(b)) * 2;
B)c = Math.sqrt(a * 2) + Math.sqrt(b * 2);
C)c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
D)c = Math.pow((Math.sqrt(a) + Math.sqrt(b)), 2);
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
64
What is the output of the following code snippet? <strong>What is the output of the following code snippet?   </strong> A)0 B)4 C)10 D)250

A)0
B)4
C)10
D)250
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
65
Assume the following variables have been declared as shown and given values elsewhere:
double a, b, c;
The discriminant of a quadratic equation is defined to be: <strong>Assume the following variables have been declared as shown and given values elsewhere: double a, b, c; The discriminant of a quadratic equation is defined to be:   Which of the following statements will assign the correct value to discriminant? </strong> A)double discriminant = Math.sqrt(b * b - 4 * a * c); B)double discriminant = Math.sqrt(b * b) - 4 * a * c; C)double discriminant = Math.sqrt(b * b) - Math.sqrt(4 * a * c); D)double discriminant = Math.sqrt(b2 - 4ac) Which of the following statements will assign the correct value to discriminant?

A)double discriminant = Math.sqrt(b * b - 4 * a * c);
B)double discriminant = Math.sqrt(b * b) - 4 * a * c;
C)double discriminant = Math.sqrt(b * b) - Math.sqrt(4 * a * c);
D)double discriminant = Math.sqrt(b2 - 4ac)
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
66
Assuming that the user inputs a value of 25000 for the pay and 10 for the bonus rate in the following code snippet, what is the output? <strong>Assuming that the user inputs a value of 25000 for the pay and 10 for the bonus rate in the following code snippet, what is the output?   </strong> A)The new pay is 25000.0 B)The new pay is 25100.0 C)The new pay is 27500.0 D)The new pay is 30000.0

A)The new pay is 25000.0
B)The new pay is 25100.0
C)The new pay is 27500.0
D)The new pay is 30000.0
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
67
Assuming that the user inputs a value of 25 for the price and 10 for the discount rate in the following code snippet, what is the output? <strong>Assuming that the user inputs a value of 25 for the price and 10 for the discount rate in the following code snippet, what is the output?   </strong> A)The new price is 25.0 B)The new price is 15.0 C)The new price is 22.5 D)The new price is 20.0

A)The new price is 25.0
B)The new price is 15.0
C)The new price is 22.5
D)The new price is 20.0
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
68
What is the value of the var variable at the end of the given code snippet? <strong>What is the value of the var variable at the end of the given code snippet?   </strong> A)0 B)1 C)30 D)31

A)0
B)1
C)30
D)31
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
69
What is the difference between the result of the following two Java statements?
I.int cents = (int)(100 * price + 0.5);
II.int cents = (100 * price + 0.5);

A)Statement I causes truncation, but II does not
B)Statement II causes truncation, but I does not
C)Statement I compiles, but II does not
D)Statement II compiles, but I does not
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
70
Which of the following statements will assign the largest value of three integer variables a, b, and c to the integer variable maximum?

A) maximum = Math.max (a, b, c);
B) maximum=Math.max (a, b);
maximum= Math.(b, c);
maximum=Math.max (a, c);
C) maximum = Math.max (a, b);
maximum = Math. max (maximum, c);
D) maximum = Math.max (a, b)+ Math.max (b, c)+ Math.max (a, c);
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
71
One way to avoid round-off errors is to use:

A)Math.sqrt()
B)Math.pow()
C)Math.round()
D)Math.truncate()
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
72
What is the output of the following statement sequence? <strong>What is the output of the following statement sequence?   </strong> A)4 B)Compile-time error C)Run-time error D)16

A)4
B)Compile-time error
C)Run-time error
D)16
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
73
What will be the value of the variables x and y after the given set of assignments? <strong>What will be the value of the variables x and y after the given set of assignments?   </strong> A)x = 40, y = 20 B)x = 20, y = 10 C)x = 10, y = 20 D)x = 20, y = 20

A)x = 40, y = 20
B)x = 20, y = 10
C)x = 10, y = 20
D)x = 20, y = 20
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
74
What is the value of Math.pow(2, 3)?

A)5.0
B)6.0
C)8.0
D)9.0
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
75
Which is the mathematical equivalent of the following Java expression? <strong>Which is the mathematical equivalent of the following Java expression?  </strong> A) h=4ab-2b/ c B) h=(4ab-2b) / c C) h=4 ab-b<sup>2</sup> / c D) h=4ab-b<sup>2</sup> / c

A) h=4ab-2b/ c
B) h=(4ab-2b) / c
C) h=4 ab-b2 / c
D) h=4ab-b2 / c
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
76
Which of the following is the Java equivalent of the following mathematical expression? <strong>Which of the following is the Java equivalent of the following mathematical expression?   </strong> A)p = 2 * Math.PI * (radius * 3); B)p = Math.PI * Math.pow(3,radius); C)p = 2 * Math.PI * Math.pow(radius, 3); D)p = 2 * Math.pow(Math.PI * radius, 3);

A)p = 2 * Math.PI * (radius * 3);
B)p = Math.PI * Math.pow(3,radius);
C)p = 2 * Math.PI * Math.pow(radius, 3);
D)p = 2 * Math.pow(Math.PI * radius, 3);
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
77
What is result of evaluating the following expression? <strong>What is result of evaluating the following expression?   </strong> A)2 B)7 C)2.5 D)3

A)2
B)7
C)2.5
D)3
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
78
What is the value of the following expression?
3 * 5 / 2 * 5

A)1.5
B)30
C)35
D)37.5
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
79
A student's class average can be computed by dividing the number of marks they have earned by the number of marks possible.Assume the following variables have been declared as shown and given values elsewhere:
int marksEarned, marksPossible;
double classPercentage;
Which of the following statements will assign the correct percentage average to classPercentage? For example, if marksEarned is 725 and marksPossible is 1000, classPercentage should be assigned the value 72.5.

A)classPercentage = marksEarned / marksPossible * 100.0;
B)classPercentage = 100 * marksEarned / marksPossible;
C)classPercentage = (100.0 * marksEarned) / marksPossible;
D)classPercentage = (100.0 + marksEarned) / marksPossible;
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
80
Which is a correct representation of the given mathematical expression in Java? <strong>Which is a correct representation of the given mathematical expression in Java?   </strong> A)a - b / 2 % 2 B)a - b / 2 C)a - (b / 2) / 2 D)(a - b / 2) / 2

A)a - b / 2 % 2
B)a - b / 2
C)a - (b / 2) / 2
D)(a - b / 2) / 2
Unlock Deck
Unlock for access to all 124 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 124 flashcards in this deck.