Consider the following class declaration. public class Sample { private int a; private double b; public Sample(int x, double y) { a = x; b = y; } // No other constructors } The following method appears in a class other than Sample. public static void test() { Sample object = new /* missing constructor call */ ; } Which of the following could be used to replace /* missing constructor call */ so that the method will compile without error?
Blog
Consider the following code segment. double d = 0.25; int i…
Consider the following code segment. double d = 0.25; int i = 3; double diff = d – i; System.out.print((int)diff – 0.5); What is printed as a result of executing the code segment?
A student has created a Car class. The class contains variab…
A student has created a Car class. The class contains variables to represent the following. A String variable called color to represent the color of the car An int variable called year to represent the year the car was made A String variable called make to represent the manufacturer of the car A String variable called model to represent the model of the car The object vehicle will be declared as type Car. Which of the following descriptions is accurate?
Consider the following code segment, which is intended to ca…
Consider the following code segment, which is intended to calculate the average of two quiz scores. double avg = 15 + 20; avg /= 2; Which of the following best describes the behavior of the code segment?
Consider the following code segment, which is intended to di…
Consider the following code segment, which is intended to display 0.5. int num1 = 5; int num2 = 10; double ans = num1 / num2; System.out.print(ans); Which of the following best describes the error, if any, in the code segment?
Consider the following code segment. int num = 1; int count…
Consider the following code segment. int num = 1; int count = 0; while (num
Consider the following code segment. int x = /* initial val…
Consider the following code segment. int x = /* initial value not shown */; int y = /* initial value not shown */; int z = x; z /= y; z += 2; Which of the following best describes the behavior of the code segment?
Consider the following code segment. double a = 7; int b =…
Consider the following code segment. double a = 7; int b = (int) (a / 2); double c = (double) b / 2; System.out.print(b); System.out.print(” “); System.out.print(c); What is printed as a result of executing the code segment?
A student has created a Song class. The class contains the f…
A student has created a Song class. The class contains the following variables. A String variable called artist to represent the artist name A String variable called title to represent the song title A String variable called album to represent the album title The object happyBirthday will be declared as type Song. Which of the following statements is true?
Consider the following code segment. int x = 4; int y = 6;…
Consider the following code segment. int x = 4; int y = 6; x -= y; y += x; Which of the following best describes the behavior of the code segment?