Exam 2: Data and Expressions
Exam 1: Introduction65 Questions
Exam 2: Data and Expressions77 Questions
Exam 3: Using Classes and Objects58 Questions
Exam 4: Writing Classes56 Questions
Exam 5: Conditionals and Loops37 Questions
Exam 6: More Conditionals and Loops36 Questions
Exam 7: Object-Oriented Design76 Questions
Exam 8: Arrays70 Questions
Exam 9: Inheritance71 Questions
Exam 10: Polymorphism70 Questions
Exam 11: Exceptions68 Questions
Exam 12: Recursion68 Questions
Exam 13: Collections68 Questions
Select questions type
Given four int values, x1, x2, y1, y2, write the code to compute the distance between the two points (x1, y1) and (x2, y2), storing the result in the double distance.
(Essay)
4.8/5
(38)
Write the paint method for an applet so that it contains 4 concentric circles (each circle is inside the previous circle), where the largest circle is bounded by a 400x400 box and the smallest is bounded by a 100x100 box. Each circle is centered on an applet that is 400x400. Make each circle a different color of your choice.
(Essay)
4.9/5
(32)
Given the following assignment statement, which of the following answers is True regarding the order that the operators will be applied based on operator precedence?
A = (b + c) * d / e - f;
(Multiple Choice)
4.9/5
(41)
What will be the result of the following assignment statement? Assume b = 5 and c = 10.
Int a = b * (-c + 2) / 2;
(Multiple Choice)
4.9/5
(30)
What is wrong with the following assignment statement?
Assume x and y are both String objects.
String z = x.equals(y);
(Essay)
4.8/5
(44)
Consider the double value likelihood = 0.013885. What would be output if DecimalFormat dformatter = DecimalFormat("0.00##"); and you execute System.out.println(df.format(likelihood)); ?
(Multiple Choice)
4.9/5
(32)
What are the syntax errors from the following program?
public class Enigma
{
public static void main(String[ ] args)
{
System.out.println("Input a String");
String x = scan.nextString( );
int size = x.length;
char last = x.charAt(size);
System.out.println("The last character in your string ", x, " is ", last);
}
}
(Essay)
4.8/5
(33)
Write an assignment statement to compute the gas mileage of a car where the int values miles_traveled and gallons_needed have already been input. The variable gas_mileage needs to be declared and should be a double.
(Essay)
4.8/5
(32)
Consider having three String variables a, b, and c. The statement c = a + b; also can be achieved by saying
(Multiple Choice)
4.8/5
(37)
Consider the following paint method and answer the questions below:
public void paint(Graphics page)
{
page.setColor(Color.blue);
page.fillRect(50, 50, 100, 100);
page.setColor(Color.white);
page.drawLine(50, 50, 150, 150);
page.drawLine(50, 150, 150, 50);
page.setColor(Color.black);
page.drawString("A nice box", 50, 170);
}
-The String "A nice box" is drawn
(Multiple Choice)
4.8/5
(41)
A double is wider than a float and a float is wider than an int.
(True/False)
4.9/5
(34)
If a, b, and c are int variables with a = 5, b = 7, c = 12, then the statement int z = (a * b - c) / a; will result in z equal to
(Multiple Choice)
4.8/5
(50)
Write a set of instructions to prompt the user for an int value and input it using the Scanner class into the variable x and prompt the user for a float value and input it using the Scanner class into the variable y.
(Essay)
5.0/5
(42)
Of the following types, which one cannot store a numeric value?
(Multiple Choice)
4.8/5
(35)
As explained in the Software Failure, the Mars Lander most likely crash landed when its descent engines cut off too high over the Mars surface.
(True/False)
5.0/5
(43)
Using the various String methods, manipulate a String called current to be current's last character followed by the remainder of its characters in order, placing the result in a String called rearranged.
(Essay)
4.9/5
(30)
Many Java drawing shapes are specified using a bounding rectangle.
(True/False)
4.8/5
(41)
Java is able to represent 255 * 255 * 255 = 16,581,375 distinct colors.
(True/False)
4.8/5
(42)
Which of the following would return the last character of the String x?
(Multiple Choice)
4.7/5
(32)
An employer has decided to award a weekly pay raise to all employees by taking the square root of the difference between his weight and the employee's weight. For instance, an employee who weighs 16 pounds less than the employer will get a $4 per week raise. The raise should be in whole dollars (an int). Assume that employerWeight and employeeWeight are both int variables that have been input, write an assignment statement to compute the int value for raise.
(Essay)
4.8/5
(38)
Showing 41 - 60 of 77
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)