Consider the following method, which is intended to calculat…

Consider the following method, which is intended to calculate and return the expression (x+y)2|a−b|.   public double calculate(double x, double y, double a, double b) { return /* missing code */; } Which of the following can replace /* missing code */ so that the method works as intended?

Consider the following method. public void doSomething() {…

Consider the following method. public void doSomething() { System.out.println(“Something has been done”); } Each of the following statements appears in a method in the same class as doSomething. Which of the following statements are valid uses of the method doSomething ? doSomething(); String output = doSomething(); System.out.println(doSomething());

Consider the processWords method. Assume that each of its tw…

Consider the processWords method. Assume that each of its two parameters is a String of length two or more. public void processWords(String word1, String word2) { String str1 = word1.substring(0, 2); String str2 = word2.substring(word2.length() – 1); String result = str2 + str1; System.out.println(result.indexOf(str2)); } Which of the following best describes the value printed when processWords is called?

The Student class has been defined to store and manipulate g…

The Student class has been defined to store and manipulate grades for an individual student. The following methods have been defined for the class. /* Returns the sum of all of the student’s grades */ public double sumOfGrades() {  /* implementation not shown */  }   /* Returns the total number of grades the student has received */ public int numberOfGrades() {  /* implementation not shown */  }   /* Returns the lowest grade the student has received */ public double lowestGrade() {  /* implementation not shown */  } Which of the following statements, if located in a method in the Student class, will determine the average of all of the student’s grades except for the lowest grade and store the result in the double variable newAverage ?

Consider the following Point2D class. public class Point2D…

Consider the following Point2D class. public class Point2D { private double xCoord; private double yCoord;     public Point2D(double x, double y) { xCoord = x; yCoord = y; } } Which of the following code segments, appearing in a class other than Point2D, will correctly create an instance of a Point2D object?