Question

What display is produced by the execution of this JAVA program if we make the following...

What display is produced by the execution of this JAVA program if we make the following call
f(0,0).
Please explain your answer


public class function {

   static void f(int x){
       System.out.println(1);
   }

   static void f(double x){
       System.out.println(2);
   }

   static void f(char x){
       System.out.println(3);
   }

   static void f(long x){
       System.out.println(4);
   }

   public static void main(String[] args) {

  
   }
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER : HERE IS THE ANSWER FOR YOUR QUESTION:

----------------------------------------------------------------------------------------------------------------

CODE:

public class function {

static void f(int x){
System.out.println(1);
}

static void f(double x){
System.out.println(2);
}

static void f(char x){
System.out.println(3);
}

static void f(long x){
System.out.println(4);
}

public static void main(String[] args) {
f(0,0);
  
}
}

----------------------------------------------------------------------------------------------------------------

SNIPPET:

1- public class function { static void f(int x){ System.out.println(1); static void f(double x){ System.out.println(2); stati

----------------------------------------------------------------------------------------------------------------

OUTPUT:

input Compilation failed due to following error(s). Main.java:20: error: no suitable method found for f(int, int) f(0,0); met

The output is due to function paramter mismatch during the function call. we are passing 2 paramters value as 0, 0 during function call but all the function defined has only one argument. thus , actaul and formal argument differ in length and compiler is not able to find the correct version of method which is having 2 paramters as input.

thus ,we get the error as shown .

----------------------------------------------------------------------------------------------------------------

I hope this would help you out.

If you like my answer , please upvote

If you have any doubt, you can provide comment /feedback below the answer

Thanks

Add a comment
Know the answer?
Add Answer to:
What display is produced by the execution of this JAVA program if we make the following...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in java Part 1 In this section, we relook at the main method by examining passing...

    in java Part 1 In this section, we relook at the main method by examining passing array as parameters. Often we include options/flags when running programs. On command line, for example, we may do “java MyProgram -a -v". Depending on options, the program may do things differently. For example, "a" may do all things while "-v" display messages verbosely. You can provide options in Eclipse instead of command line: "Run ... Run Configurations ... Arguments". Create a Java class (Main.java)....

  • What output is produced by the following program? public class MysteryNums public static void main(String[] args)...

    What output is produced by the following program? public class MysteryNums public static void main(String[] args) - int x = 12; int y = x - 3; 3, sentence (y, x + y); . public static void sentence (int numi, int num2) { 4: System.out.println(num1 + " + num2);

  • 1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program!...

    1) Consider the following Java program: 1 public class HelloWorld { 2     // My first program! 3     public static void main(String[] args) { 4         System.out.println("Hello, World!"); 5     } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...

  • Help with a question in Java: What is the output from the following program? public class...

    Help with a question in Java: What is the output from the following program? public class Methods2 { public static void main(String[] args) { for (int i = 0; i < 3; i++) { for (int j = 0; j <= i; j++){ System.out.print(fun(i, j) + "\t"); } System.out.println(); } } static long fun(int n, int k) { long p = 1; while (k > 0){ p *= n; } return p; } }

  • Java questions QUESTION 8 Assume the following classes are each defined in their own java files...

    Java questions QUESTION 8 Assume the following classes are each defined in their own java files and compile public class A public void display { System.out.println("A's display"); public class B extends A{ public void display { System.out.println("B's display"); public class C extends A public void display { System.out.println("C's display"); public class D { public static void main(String args) { 3: int i = ((int)(Moth.random(* 10)) if (i == 0) a = new BO: else if (i == 1) a =...

  • What is the output for the following program codes? a) [ 0.5 Mark ] class A...

    What is the output for the following program codes? a) [ 0.5 Mark ] class A { int i; } class B extends A { int j; void display() { super.i = j + 1; System.out.println(j + " " + i); }} class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); }} OUTPUT: b) [ 0.5 Mark ] class Parent { public void getBike(){ System.out.println("Suzuki Bike"); }} class Child extends Parent {...

  • What is the output of this program? class A { public int i; private int j;...

    What is the output of this program? class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class Inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } } Java language!! // include explanation!

  • What will the following program display? public class checkpoint { public static void main(String urgs[]) {...

    What will the following program display? public class checkpoint { public static void main(String urgs[]) { int n = 1776; doubled = 110.0901; System .out.println(n + “\t” + d); myMethod(n, d); System.out.println(n + “\t” + d); } public static void myMethod(int i, double x) { System.out.printing + “\t” + x); i = 1250; x= 199.99; System.out.println(i + “\t" + x); } } Write the following two methods: i. compute Diameter; This method accepts the radius (r) of a circle, and...

  • Java please answer A to I please dont type the answer on paper please use the...

    Java please answer A to I please dont type the answer on paper please use the computer A.   Explain why alpha cannot be accessed by other members of its class. B.   In the program, how can you determine the type of access modifier? C.   Describe the differences and similarities of beta and gamma in program, within the context of access specifiers and class member accessibility. D.   Explain how objects, a and b, are passed to the method. E.    Why...

  • Java. What is the output of this code? Ace.java public class Ace { private double a;...

    Java. What is the output of this code? Ace.java public class Ace { private double a; public Ace ( double x) {       a = x; } public void multiply (double f) {       a *= x;         } public String toString () {       return String.format ("%.3f", x); AceDem.java public class AceDemo { public static void main(String args[]) {    Ace card = new Ace (2.133); card.multiply (.5); System.out.println (card); } }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT