Question :
11.What will be the value of bonus after the following : 2007988
11.What will be the value of bonus after the following code is 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;
a.200
b.500
c.750
d.1000
e.1250
12.What would be the value of bonus after the following statements are executed?
int bonus, sales = 1250;
if (sales > 1000)
bonus = 100;
if (sales > 750)
bonus = 50;
if (sales > 500)
bonus = 25;
else
bonus = 0;
a.100
b.500
c.25
d.0
13.What would be the value of bonus after the following statements are executed?
int bonus, sales = 85000;
char dept = 'S';
if (sales > 100000)
if (dept == 'R')
bonus = 2000;
else
bonus = 1500;
else if (sales > 75000)
if (dept == 'R')
bonus = 1250;
else
bonus = 1000;
else
bonus = 0;
a.2000
b.1500
c.1250
d.1000
14.Which of the following is the correct boolean expression to test for: int x being a value between, but not including, 500 and 650, or int y not equal to 1000?
a.((x >= 500 && x <= 650) && (y != 1000))
b.((x > 500 AND x < 650) OR !(y.equal(1000)))
c.((x > 500 && x < 650) || (y != 1000))
d.((x < 500 && x > 650) || !(y == 1000))
15.If str1 and str2 are both Strings, which of the following will correctly test to determine whether str1 is less than str2?
(1) (str1 < str2)
(2) (str1.equals(str2) < 0)
(3) (str1.compareTo(str2) < 0)
a.1, 2, and 3 will all work
b.2
c.3
d.2 and 3
16.To do a case insensitive compare which of the following could be used to test the equality of two strings, str1 and str2?
a.(str1.equalsIgnoreCase(str2))
b.(str1.compareToIgnoreCase(str2) == 0)
c.Only a
d.a and b
17.What will be the value of pay after the following statements are executed?
int hours = 45;
double pay, payRate = 10.00;
pay = hours <= 40 ? hours * payRate :
40 * payRate + (hours - 40) * payRate * 1.5;
a.400.00
b.450.00
c.465.00
d.475.00
18.What would be the value of x after the following statements were executed?
int x = 10;
switch (x)
{
case 10:
x += 15;
case 12:
x -= 5;
break;
default:
x *= 3;
}
a.5
b.20
c.25
d.30
19.What will be printed when the following code is executed?
double x = 45678.259;
DecimalFormat formatter =
new DecimalFormat("#,###,##0.00");
System.out.println(formatter.format(x));
a.45678.259
b.0,045,678.26
c.45,678.26
d.45,678.3
20.Which of the following will format .1278 to display as 12.8%?
a.000.0%
b.#0.00%
c.###.##%
d.##0.0%