Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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) {

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. Employees and managers participate in development of the system.

Answered: 1 week ago