Java | JSP | JSF Answers

Questions answered by Experts: 3 611

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

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.


. Suppose that you have the following statements:
String str;
str = "Java programming: from problem analysis to program design";
What is the value of the following expressions?
a. str.indexOf("analysis")
b. str.substring(5, 16)
c. str.startsWith("Java")
d. str.startsWith("J")
e. str.endsWith(".")
Write a program that computes the cost of painting and installing carpet in a
room. Assume that the room has one door, two windows, and one bookshelf. Your program must do the following:
a. Prompts the user to enter, in feet, the length, width, and height of a
room. Read the dimensions of the room.
b. Prompts the user to enter the widths and heights, in feet, of the door,
each window, and the bookshelf. Read these quantities.
c. Prompts the user to enter the cost, per square foot, of painting the
walls. Read these quantities.
d. Prompts the user to enter of cost, per square foot, of installing carpet.
Read these quantities.
LATEST TUTORIALS
APPROVED BY CLIENTS