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)
Question
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)
Solution
The correct method declaration is:
b. public static void computeSum(double a, double b)
This is because in Java, the method declaration starts with the access modifier (public), followed by the keyword static (since it's a static method), then the return type (void, meaning it doesn't return anything), the method name (computeSum), and finally the parameters in parentheses. Each parameter includes its type (double) and name (a, b).
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)
A public static method named computeSum() is located in ClassA. To call the method from within ClassB, use the statement _____. a. ClassA.computeSum(); b. ClassB(computeSum()); c. ComputeSum(ClassA); d. You cannot call computeSum() from within ClassB.
The method with the declaration public static int aMethod(double d) is a method type of _____. a. static b. int c. double d. You cannot determine the method type.
Which of the following is an example of a non-static method? (Select whichever applicable)Question 9Answera.void displayMessage() {}b.public static void printName() {}c.public void calculateSum() {}d.private static int x = 10;
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.