Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Rewrite the following expressions using an if...else statement. (Assume
that all variables are declared properly.)
(fuel >= 10) ? drive = 150 : drive = 30;
Rewrite the following expressions using the conditional operator. (Assume
that all variables are declared properly.)
if (hours >= 40.0)
wages = 40 * 7.50 + 1.5 * 7.5 * (hours - 40);
else
wages ¼ hours * 7.50;
Suppose that score is an int variable. Consider the following if statements:
if (score >= 90);
System.out.println("Discount = 10%");
a. What is the output if the value of score is 95? Justify your answer.
b. What is the output if the value of score is 85? Justify your answer.
Suppose that overSpeed and fine are double variables. Assign the value
to fine as follows: If 0 < overSpeed <= 5, the value assigned to fine is
$20.00; if 5 < overSpeed <= 10, the value assigned to fine is $75.00; if 10 <
overSpeed <= 15, the value assigned to fine is $150.00; if overSpeed > 15,
the value assigned to fine is $150.00 plus $20.00 per mile over 15.
What is the output of the following program?
public class Exercise9
{
public static void main(String[] args)
{
int myNum = 10;
int yourNum = 30;
if (yourNum % myNum == 3)
{
yourNum = 3;
myNum = 1;
}
else if (yourNum % myNum == 2)
{
yourNum = 2;
myNum = 2;
}
else
{
yourNum = 1;
myNum = 3;
}
System.out.println(myNum + " " + yourNum);
}
}
. Suppose that x, y, z, and w are int variables and x = 3, y = 4, z = 7, and w = 1.
What is the output of the following statements?
a. System.out.println("x == y: " + (x == y));
b. System.out.println("x != z: " + (x != z));
c. System.out.println("y == z – 3: " + (y == z – 3));
d. System.out.println("!(z > w): " + !(z > w));
e. System.out.println("x + y < z: " + (x + y < z));
Select the best answer.
a. if (6 < 2 * 5)
System.out.print("Hello");
System.out.print(" There");
outputs the following:
i. Hello There ii. Hello iii. Hello iv. There
There
b. if ('a' > 'b' || 66 > (int)('A'))
System.out.println("#*#");
outputs the following:
i. #*# ii. # iii. * iv. none of these
*
#
c. if (7 <= 7)
System.out.println(6 - 9 * 2 / 6);
outputs the following:
i. -1 ii. 3 iii. 3.0 iv. none of these
d. if (7 < 8)
{
System.out.println("2 4 6 8");
System.out.println("1 3 5 7");
}
outputs the following:
i. 2 4 6 8 ii. 1 3 5 7 iii. none of these
1 3 5 7
e. if (5 < 3)
System.out.println("*");
else if (7 == 8)
System.out.println("&");
else
System.out.println("$");
outputs the following:
i. * ii. & iii. $ iv. none of these
Briefly explain what a method is and describe the three main parts of a
method.

By making use of an example, show how method overloading takes place. Also
indicate how overloaded methods can be called from mainline logic.

By means of examples, explain what programming environments and user environments refer to.


 java code for statement:a state is divided into r*c cities.the government has launched an initiative to find the cities w... a state is divided into r*c cities.the government has launched an initiative to find the cities which are dominated by coders. each city may or may not have coders residing in it. if the city is dominated by coders, it is marked with 1 else it is marked with 0. two cities are termed as connected cities if they both are dominated by coders and can be reached by moving vertically, horizontally, or diagonally.


LATEST TUTORIALS
APPROVED BY CLIENTS