Question: a) Consider the following program: public class Test ? public static void main(String[] args) { System.out.print (xMethod (5.72)); } public static int xMethod(int n) {

![void main(String[] args) { System.out.print (xMethod (5.72)); } public static int xMethod(int](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f451de9757d_77366f451ddf3806.jpg)
a) Consider the following program: public class Test ? public static void main(String[] args) { System.out.print (xMethod (5.72)); } public static int xMethod(int n) { System.out.print("int")); return n;) public static int xMethod (long n) { System.out.print("long")); return n;) i) Identify the error for the above program. (2 marks) Suggest solution to correct the error without adding more lines to the code. 12. market b) Write overloaded static methods for the following problems: 1) The first function receives two integers arrays and return 1 If both arrays are equal (both arrays have the same elements at the same position). (3 marks) The second function receives two strings and return 1 If the two strings are equal, irrespective of the case (lower or upper) of the strings, return 1 if the two strings are equal and return 0 otherwise. (3 marks) In the main method, invoke all the above methods in Question 1 b) 1) -ii). (2 marks) c) Suppose you have a class named as Number. Write a method that will display numbers from 1 to n, 7 numbers per line. The numbers are separated by one space. The method headeris as follows: public static void displayNumber(int n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
