Which of the following declarations are correct? Please select all that apply.Group of answer choicespublic static void print(String... strings, double... numbers)public static void print(double... numbers, String name)public static double... print(double d1, double d2)public static void print(double... numbers)public static void print(int n, double... numbers)
Question
Which of the following declarations are correct? Please select all that apply.Group of answer choicespublic static void print(String... strings, double... numbers)public static void print(double... numbers, String name)public static double... print(double d1, double d2)public static void print(double... numbers)public static void print(int n, double... numbers)
Solution
The correct declarations are:
public static double... print(double d1, double d2) public static void print(double... numbers) public static void print(int n, double... numbers)
The first two declarations are incorrect because in Java, a method can only have one varargs parameter and it must be the last parameter.
Similar Questions
Which of the following method declarations is correct for a static method named displayFacts() if the method receives an int argument? a. public static int displayFacts() b. public void displayFacts(int data) c. public static void displayFacts(int data) d. public void displayFacts(static int)
which of the following declarations is INCORRECT?A. String s = "Hi!";B. int[] ar = new int(3);C. double d = 1.3E + 21;D. double d = 1.3D;
Which of the following method declarations is correct for a static method named computeSum() if the method receives two double arguments? a. public static double, double computeSum() b. public static void computeSum(double a, double b) c. public int computeSum(double a, double b) d. public static int computeSum(double a, b)
Which of the following are true about the following code? (Choose all that apply)public class Create { Create() { System.out.print("1 "); } Create(int num) { System.out.print("2 "); } Create(Integer num) { System.out.print("3 "); } Create(Object num) { System.out.print("4 "); } Create(int... nums) { System.out.print("5 "); } public static void main(String[] args) { new Create(100); new Create(1000L); }}*A. The code prints out 2 4.B. The code prints out 3 4.C. The code prints out 4 2.D. The code prints out 4 4.E. The code prints 3 4 if you remove the constructor Create(int num).F. The code prints 4 4 if you remove the constructor Create(int num).G. The code prints 5 4 if you remove the constructor Create(int num).
Which of the following will compile when inserted in the following code? (Choose all that apply)public class Order3 { final String value1 = "1"; static String value2 = "2"; String value3 = "3"; { // CODE SNIPPET 1 } static { // CODE SNIPPET 2 }}*A. value1 = "d"; instead of // CODE SNIPPET 1B. value2 = "e"; instead of // CODE SNIPPET 1C. value3 = "f"; instead of // CODE SNIPPET 1D. value1 = "g"; instead of // CODE SNIPPET 2E. value2 = "h"; instead of // CODE SNIPPET 2F. value3 = "i"; instead of // CODE SNIPPET 2
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.