A method is declared as public static void showResults(double d, int i). Which of the following is a correct method call? a. showResults(double d, int i); b. showResults(12.2, 67); c. showResults(4, 99.7); d. Two of these are correct.
Question
A method is declared as public static void showResults(double d, int i). Which of the following is a correct method call? a. showResults(double d, int i); b. showResults(12.2, 67); c. showResults(4, 99.7); d. Two of these are correct.
Solution
The correct answer is b. showResults(12.2, 67);
Here's why:
a. showResults(double d, int i); - This is incorrect because you are not supposed to pass the data types (double, int) in the method call. You should pass the actual values.
b. showResults(12.2, 67); - This is correct. The method expects a double and an int as parameters. 12.2 is a double and 67 is an int.
c. showResults(4, 99.7); - This is incorrect. The method expects a double first and then an int. Here, an int is passed first and then a double.
d. Two of these are correct. - This is incorrect because only one of the above options is correct.
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 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)
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 could be the last legally coded line of a method declared as public static int getVal(double sum)? a. return; b. return 77; c. return 2.3; d. Any of these could be the last coded line of the method.
The method with the declaration public static char procedure(double d) has a method type of _____. a. public b. static c. char d. double
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.