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

----------------------------------------------------------------------------------------------------------------
OUTPUT:

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
What display is produced by the execution of this JAVA program if we make the following...
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) - 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! 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 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 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 { 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; } 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[]) { 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 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...
PLEASE HELP DEBUG THE FOLLOWING JAVA PROGRAM // Program displays some facts about a string public class DebugSeven3 { public static void main(String[] args) { String quote = "Honesty is the first chapter in the book of wisdom. - Thomas Jefferson"; System.out.println("index.of('f') is: " + indexOf('f')); System.out.println("index.of('x') is: " + indexOf('x')); System.out.println("char.At(5) is: " + charAt(5)); System.out.println("endsWith(\"daughter\") is: " + quote.endswith("daughter")); System.out.println("endsWith(\"son\") is: " + quote.endswith("son")); System.out.println("replace('e', '*') is: "...