Assuming the following declarations: int x = 5, y = 2, z =…
Assuming the following declarations: int x = 5, y = 2, z = 10, temp = 0; What is the output of the following statement? If it causes an error, just type error. If nothing is output, just type no output. if ( x + y > z ) { x = y + z; } else { x = y – z; }System.out.println( x + ” ” + y + ” ” + z );
Read DetailsConsider the following method. public double oneMethod(int a…
Consider the following method. public double oneMethod(int a, boolean b) { /* implementation not shown */ } Which of the following lines of code, if located in a method in the same class as oneMethod, will compile without error?
Read DetailsWhat is the output of the following code fragment? Assume al…
What is the output of the following code fragment? Assume all the variables are declared. if(( 5.2 > 3.3 && 6.2 < 9.9) && (6.2 < 3.5 || 4.2 == 3.1 || 3.1 != 3.14)) { System.out.print("TRUE");}else { System.out.print("FALSE");}
Read DetailsA store sells rope only in whole-foot increments. Given thre…
A store sells rope only in whole-foot increments. Given three lengths of rope, in feet, the following code segment is intended to display the minimum length of rope, in feet, that must be purchased so that the rope is long enough to be cut into the three lengths. For example, for lengths of 2.8 feet, 3 feet, and 5 feet, the minimum length of rope that must be purchased is 11 feet. For these values, the code segment should display 11. As another example, for lengths of 1.1 feet, 3.2 feet, and 2 feet, the minimum length of rope that must be purchased is 7 feet. For these values, the code segment should display 7. In the following code segment, len1, len2, and len3 are properly declared and initialized double variables representing the three lengths of rope. double total = len1 + len2 + len3; int minLength = (int) (total + 0.5); System.out.print(minLength); Which of the following best describes the behavior of the code segment?
Read DetailsConsider the three code segments. What is the output of the…
Consider the three code segments. What is the output of the programs? Block-Based Pseudo-Code The pseudocode initializes list with values. It inserts 99 at positions 2, 3, and 4. A FOR EACH loop then displays every item in the updated list. Python Program-Code list = [11,22,33,44,55]list.insert(1,99)list.insert(2,99)list.insert(3,99)for item in list: print(item,end=” “) Text-Based Pseudo-Code list ← [11,22,33,44,55]INSERT (list, 2, 99)INSERT (list, 3, 99)INSERT (list, 4, 99)FOR EACH item IN list{ DISPLAY (item)}
Read DetailsThe volume of a cylinder is equal to the height times the ar…
The volume of a cylinder is equal to the height times the area of the circular base. The area of the circular base is equal to π (pi) times the square of the radius. The following code segment is intended to compute and print the volume of a cylinder with radius r and height h. Assume that the double variables r, h, and pi have been properly declared and initialized. /* missing code */ System.out.print(volume); Which of the following cannot be used to replace /* missing code */ so that the code segment works as intended?
Read Details