GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Consider the following incomplete method, which is intended…

Consider the following incomplete method, which is intended to return true if the value of y is between the values of the other two parameters and false otherwise. /** Precondition: x, y, and z have 3 different values. */public static boolean compareThree(int x, int y, int z){ return /* missing condition */ ;} The following table shows the results of several calls to compareThree. compareThree Table Call Result compareThree(4, 5, 6) true compareThree(6, 5, 4) true compareThree(5, 4, 6) false compareThree(3, 4, 4) violates precondition Which of the following can be used to replace / * missing condition * / so that compareThree will work as intended when called with parameters that satisfy its precondition?

Read Details

The Vbox class includes the following two constructors.   V…

The Vbox class includes the following two constructors.   Vbox Constructors Constructor Signature Explanation public vBox(int w, int h, int d) Constructs a Vbox object that represents a box with width w, height h, and depth d. public vBox(int len) Constructs a Vbox object that represents a box with width len, height len, and depth len.   Which of the following declarations, appearing in a class other than Vbox, will correctly instantiate a Vbox object?

Read Details

What does the post-increment operator ++ do?

What does the post-increment operator ++ do?

Read Details

What debugging technique involves explaining your code line-…

What debugging technique involves explaining your code line-by-line to someone else?

Read Details

What is a library in programming?

What is a library in programming?

Read Details

Consider the following incomplete method. public int somePro…

Consider the following incomplete method. public int someProcess(int n){ /* body of someProcess */} The following table shows several examples of input values and the results that should be produced by calling someProcess. Table of Examples Input Value n Value Returned by someProcess(n) 3 30 6 60 7 7 8 80 9 90 11 11 12 120 14 14 16 160 Which of the following code segments could be used to replace /* body of someProcess */ so that the method will produce the results shown in the table? I.if((n % 3 == 0) && (n % 4 == 0) return n * 10;else return n;II.if((n % 3 == 0) || (n % 4 == 0))    return n * 10;return n;III.if(n % 3 == 0)    if(n % 4 == 0) return n * 10;return n;

Read Details

Determine if the following evaluates to true or false based…

Determine if the following evaluates to true or false based on the value of these variables:   int a = 0;int b = 1;   (a == 0 || b == 2);

Read Details

Consider the following code segment. String greet1 = “Good m…

Consider the following code segment. String greet1 = “Good morning!”;String greet2 = “Good afternoon!”;String greet3 = “Good evening”;int timeOfDay;if(timeOfDay >= 1700) { System.out.println(greet3);}else if(timeOfDay >= 1200) { System.out.println(greet2);}else { System.out.println(greet1);} What is printed as a result of executing the code segment if timeOfDay equals 1900?

Read Details

Assume that the boolean variables a, b, c, and d have been d…

Assume that the boolean variables a, b, c, and d have been declared and initialized. Consider the following expression. !(!(a && b)||(c||!d)) Which of the following is equivalent to the expression?

Read Details

Assume that the int variables x, y, z, and low have been pro…

Assume that the int variables x, y, z, and low have been properly declared and initialized. The code segment below is intended to print the sum of the greatest two of the three values but does not work in some cases.   if(x > y && y > z){   low = z;}if(x > y && z > y){   low = y;}else {   low = x;}System.out.println(x + y + z – low); For which of the following values of x, y, and z does the code segment NOT print the correct value?

Read Details

Posts pagination

Newer posts 1 … 878 879 880 881 882 … 87,273 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top