menu
bartleby
search
close search
Hit Return to see all results

1. (Method Overloadinq) Given the following methods, write down the printed output of themethod calls:public static void doSomething(String x)System.out.println("A");public static void doSomething(int x)System.out.println("B");public static void doSomething(double x)System.out.println("C");public static void doSomething(String X, inty)System.out.println("D");public static void doSomething(int X, String y)System.out.printin("Е");public static void doSomething(double x, int y)System.out.println("F");Method calls1. doSomething(5);2. doSomething (5.2, 9);3. doSomething(3, "Hello");4. doSomething("Able", 8);5. doSomething ("Alfred");6. doSomething (3.6);7. doSomething("World");

Question

Use eclipse for these methods

1. (Method Overloadinq) Given the following methods, write down the printed output of the
method calls:
public static void doSomething(String x)
System.out.println("A");
public static void doSomething(int x)
System.out.println("B");
public static void doSomething(double x)
System.out.println("C");
public static void doSomething(String X, inty)
System.out.println("D");
public static void doSomething(int X, String y)
System.out.printin("Е");
public static void doSomething(double x, int y)
System.out.println("F");
Method calls
1. doSomething(5);
2. doSomething (5.2, 9);
3. doSomething(3, "Hello");
4. doSomething("Able", 8);
5. doSomething ("Alfred");
6. doSomething (3.6);
7. doSomething("World");
help_outline

Image Transcriptionclose

1. (Method Overloadinq) Given the following methods, write down the printed output of the method calls: public static void doSomething(String x) System.out.println("A"); public static void doSomething(int x) System.out.println("B"); public static void doSomething(double x) System.out.println("C"); public static void doSomething(String X, inty) System.out.println("D"); public static void doSomething(int X, String y) System.out.printin("Е"); public static void doSomething(double x, int y) System.out.println("F"); Method calls 1. doSomething(5); 2. doSomething (5.2, 9); 3. doSomething(3, "Hello"); 4. doSomething("Able", 8); 5. doSomething ("Alfred"); 6. doSomething (3.6); 7. doSomething("World");

fullscreen
check_circleAnswer
Step 1

Solution:

Given data,

The java code to display the output for method calls using the method overloading is given below:

Method overloading:

The method overloading is a ability of class to have same name for multiple methods with different argument list. The arguments in overloaded method can vary in number or in types or both.

 

The program has the following algorithm:

 

  • Define the class “Sample”.
  • In the main() method,
  • Call doSomething(5) method with arguments of integer value. So, it displays the text “B”.
  • Call doSomething(5.2, 9) method with arguments of double and integer value. So, it displays the text “F”.
  • Call doSomething(3, "Hello") method with arguments of integer and string value. So, it displays the text “E”.
  • Call doSomething("Able", 8) method with arguments of string and integer value. So, it displays the text “D”.
  • Call doSomething("Alfred") method with arguments of string value. So, it displays the text “A”.
  • Call doSomething(3.6) method with arguments of double value. So, it displays the text “C”.
  • Call doSomething("world") method with arguments of double value. So, it displays the text “A”.
Step 2

Screenshot of program:

fullscreen
Step 3
fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Our solutions are written by experts, many with advanced degrees, and available 24/7

See Solution
Tagged in

Engineering

Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: write a program to convert between KPH and MPH in either direction. in Eclipse.If you are driving ac...

A: Hey,,,We  have to use scanner class  to get input .So we will import scanner package to access the s...

question_answer

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Solution:The C++ program has the following algorithm:Declare and initialize the required variables.D...

question_answer

Q: I have a question about blockchain technologies. The question states "Describe three components of b...

A: Solution:Blockchain technologies:Blockchain is a technology which permits the digital data to be dis...

question_answer

Q: Write a complete C++ program that randomly generates 20 integers between the rangeof 1 to 50 and sto...

A: The random number is generated by using rand() function from stdlib.h and in order to generate a new...

question_answer

Q: Task_1: Base-10 conversion of the following Base-2 values? 101101   2. 011101   3. 1001   4. 11111...

A: Conversion of Base-2 to Base-10: 1. 101101:

question_answer

Q: I need ERD Model Arrow Electronics is a consumer electronics retailer operating in the United States...

A: The 8 entities are indicated below with only their unqiue identifier (bold) and one or more other at...

question_answer

Q: Function Name: comboLock Parameters: num1 – a positive integer representing the first digit in the c...

A: Solution: The following function checks whether the five integers is in the order (odd, even, odd, e...

question_answer

Q: Write a program in Eclipse that prompts the user for first name, last name, then secret number. The ...

A: Program plan:Include the required header file.Define the class “Main”.Define the “defaultInfo” metho...

question_answer

Q: Use Eclipse for do this program. Show the output of the following statements.a) System.out.printf("a...

A: The program has the following algorithm:a) The statement print the amount in floating point and expo...

Sorry about that. What wasn’t helpful?