Java Programming, Loose-leaf Version
8th Edition
ISBN: 9781337685917
Author: Joyce Farrell
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 10RQ
Program Description Answer
The legally coded return statement for the method with the declaration “public static int getVal(double sum)” is “return 77”.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Which of the following is true for a method have int return type?
a)The method can have only one return statement within one-way if
b)The method having only return statement within if must be two-way
c)The method need not have a return statement
d)The return statement should not be within if
Which of the following will compile successfully?
1.)
public int methodC() {
return;
}
2.)
public int methodC() {
return 0;
}
3.)
public void methodA() {
return null;
}
4.)
public int methodB() {
return 9.0;
}
Suppose you have declared a variable as int myAge = 21;. Which of the following is a legal call to a method with the following declaration?private static void AMethod(int num)
a. AMethod(myAge);
b. AMethod(int myAge);
c. AMethod();
d. AMethod(int 55);
Chapter 3 Solutions
Java Programming, Loose-leaf Version
Ch. 3 - Prob. 1RQCh. 3 - Prob. 2RQCh. 3 - Prob. 3RQCh. 3 - Prob. 4RQCh. 3 - Prob. 5RQCh. 3 - Prob. 6RQCh. 3 - Prob. 7RQCh. 3 - Prob. 8RQCh. 3 - Prob. 9RQCh. 3 - Prob. 10RQ
Ch. 3 - Prob. 11RQCh. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Prob. 14RQCh. 3 - Prob. 15RQCh. 3 - Prob. 16RQCh. 3 - Prob. 17RQCh. 3 - Prob. 18RQCh. 3 - Prob. 19RQCh. 3 - Prob. 20RQCh. 3 - Prob. 1PECh. 3 - Prob. 2PECh. 3 - Prob. 3PECh. 3 - Prob. 4PECh. 3 - Prob. 5PECh. 3 - Prob. 6PECh. 3 - Prob. 7PECh. 3 - Prob. 8PECh. 3 - Prob. 9PECh. 3 - Prob. 10PECh. 3 - Prob. 11PECh. 3 - Prob. 12PECh. 3 - Prob. 13PECh. 3 - Prob. 1GZCh. 3 - Prob. 2GZCh. 3 - Prob. 1CP
Knowledge Booster
Similar questions
- Which of the following pairs of method declarations represent correctly overloaded methods? a. private static void MethodB(double d) private static void MethodB() b. private static double MethodC(int e) private static double MethodD(int f) c. Two of these are correctly overloaded methods. d. private static void MethodA(int a) private static void MethodA(int b, double c)arrow_forward2.Which of the following is the correct way to define an initializer method? A. def __init__(title, author): B. def __init__(): C. __init__(self, title, author): D. def __init__(self, title, author):arrow_forwardWhich of the following pairs of method declarations represent correctly overloaded methods? a. private static void Method(double d) private static int Method() b. Two of these are correctly overloaded methods. c. private static double Method(int e) private static int Method(int f) d. private static void Method(int a) private static void Method(int b)arrow_forward
- Which of the options below is correct for myMethod having return type as double. It is invoked in main method as int a = myMethod(); ? a)There is no error b)Declaration of a must be double as return type is double c)There must be at least one parameter d)Declaration and invocation must be on separate linesarrow_forwardWhich of the following is false? a)There can be more than one parameter for a method b)There can be more than one return type for a method c)There can be zero or one return type for a method d)There can be zero or one parameter for a methodarrow_forwardWhich of the following statements correctly shows the first line of a method definition? A. class method display(self): B. method display(self): C. display(self): D. def display(self):arrow_forward
- Which of the following statements are true about static methods.? Static methods do not need an object in a class to be invoked. Math.sin(x) is an example of a static method. Inside a class, a static method belonging to the class can be invoked by using its name. Outside a class, a static method is invoked by using the name of the class - like Math,pow. All of the above are true statements about static methods.arrow_forwardWhat is the output when calling the following method with mystery (2,4)? Select one: a. 12 b. 24 c. 6 d. 10arrow_forwardWrite a method that returns the lcm (least common multiple) of an unspecified number of integers. The method header is specified as follows: public static int lcm(int... numbers) Write a test program that prompts the user to enter five numbers, invokes the method to find the lcm of these numbers, and displays the lcm.arrow_forward
- Which is not a type of method parameter in C#? a. output b. reference c. forensic d. valuearrow_forwardWhat value is returned from the following method? public static double methodA() { double a = 8.5 + 9.5; return a; }arrow_forwardWhich constructor among the following will be called if a call is made like className(5,’b’);? a) className(int x=5,char c=’b’); b) int className(int x, char c, char d); c) className(int x, char c, int y); d) char className(char c,int x);arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage