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 ?
Blog
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?
Consider the following code segment. int val = 48; int div…
Consider the following code segment. int val = 48; int div = 6; while ((val % 2 == 0) && div > 0) { if (val % div == 0) { System.out.print(val + ” “); } val /= 2; div–; } What is printed when the code segment is executed?
Consider the following code segment. int num = 1; while (nu…
Consider the following code segment. int num = 1; while (num < 5) { System.out.print("A"); num += 2; } What is printed as a result of executing the code segment?
Consider the following code segment. int k = 0; while (k < 1...
Consider the following code segment. int k = 0; while (k < 10) { System.out.print((k % 3) + " "); if ((k % 3) == 0) k = k + 2; else k++; } What is printed as a result of executing the code segment?
Consider the following method. public int sol(int lim)…
Consider the following method. public int sol(int lim) { int s = 0; for (int outer = 1; outer
Consider the following code segment. int val = 1; while (va…
Consider the following code segment. int val = 1; while (val
Consider the following method. public int mystery(int num) {…
Consider the following method. public int mystery(int num) { int x = num; while (x > 0) { if (x / 10 % 2 == 0) return x; x = x / 10; } return x; } What value is returned as a result of the call mystery(1034) ?
Consider the following code segment. int k = 1; while (k < 2...
Consider the following code segment. int k = 1; while (k < 20) { if ((k % 3) == 1) System.out.print(k + " "); k++; } What is printed as a result of executing this code segment?
Consider the following method, which is intended to count th…
Consider the following method, which is intended to count the number of times the letter “A” appears in the string str. public static int countA(String str) { int count = 0; while (str.length() > 0) { int pos = str.indexOf(“A”); if (pos >= 0) { count++; /* missing code */ } else { return count; } } return count; } Which of the following should be used to replace /* missing code */ so that method countA will work as intended?