Computer Science, asked by dd0166900, 2 months ago

Predict the output.

class X

{

void display(int a)

{

System.out.println("INT");

}



void display(double d)

{

System.out.println("DOUBLE");

}

}



public class Sample

{

public static void main(String[] args)

{

new X().display(100);

}

}


Select one:

Ambiguity error
Compilation Fails
INT
DOUBLE

Answers

Answered by aadarsh2610
3

Explanation:

Predict the output.

class X

{

void display(int a)

{

System.out.println("INT");

}

void display(double d)

{

System.out.println("DOUBLE");

}

}

public class Sample

{

public static void main(String[] args)

{

new X().display(100);

}

}

Answered by Jasleen0599
0

Option A) Ambiguity error

class X

{

void display(int a)

{

System.out.println("INT");

}

void display(double d)

{

System.out.println("DOUBLE");

}

}

public class Sample

{

public static void main(String[] args)

{

new X().display(100);

}

}

  • Ambiguity errors happen when two generic declarations that seem to be mutually exclusive resolve to the same erased type, resulting in a conflict.
  • The challenges that the Java language definition does not explicitly describe are known as ambiguities. Our views are supported by the various outputs generated by various compilers on a number of example programmes.
  • The challenges that the Java language definition does not explicitly describe are known as ambiguities. Our views are supported by the various outputs generated by various compilers on a number of example programmes.
  • When you derive classes, confusion may arise if the members of the base and derived classes share the same names. If you use a name or qualified name that doesn't correspond to a specific function or object, access to a base class member is unclear.

#SPJ2

Similar questions