Question

What will the following Java code snippet output when executed, which uses a simple constructor and method overloading ? class Calculator {     int add ( int a, int
b) {         return a + b;     }     double add ( double a, double
b) {         return a + b;     }     public static void main (String[] args) {         Calculator calc = new Calculator ();         System.out.println(calc.add( 5 , 10 ));      // Line 1         System.out.println(calc.add( 5.5 , 10.5 ));  // Line 2     }}                             

A 15, 16.0
B 15.0, 16.0
C 15, 16
D 10, 10
E Compilation error due to method overloading
Practice Next

Hey! Ask a query