Related questions with answers
Question
Identify and correct the errors in the following program: 1 public class Test { 2 public static method1(int n, m) { 3 n += m; 4 method2(3.4); 5 } 6 7 public static int method2(int n) { 8 if (n > 0) return 1; 9 else if (n == 0) return 0; 10 else if (n < 0) return −1; 11 } 12 }
Solution
VerifiedAnswered 1 year ago
Answered 1 year ago
Step 1
1 of 3In method1 parameters are not declared correctly. m must be given a type. method1 also has to have defined type. In this case it doesn't return a value so it is void method.
public static void method1(int n, int m)
method2 does not take floating point number as argument, so 3.4 is not a correct input. We can change that to n for example:
method2(n);
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Recommended textbook solutions

Computer Organization and Design MIPS Edition: The Hardware/Software Interface
5th Edition•ISBN: 9780124077263David A. Patterson, John L. Hennessy226 solutions

Intro to Java Programming, Comprehensive Version
10th Edition•ISBN: 9780133761313Y. Daniel Liang1,628 solutions

Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe895 solutions

Introduction to Algorithms
3rd Edition•ISBN: 9780262033848 (5 more)Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen849 solutions
More related questions
- computer science
- computer science
1/4
- computer science
- computer science
1/7