Examveda
Examveda

What will be the output of the following Java code?
class overload 
{
     int x;
double y;
     void add(int a , int b) 
     {
         x = a + b;
     }
     void add(double c , double d)
     {
         y = c + d;
     }
     overload() 
     {
         this.x = 0;
         this.y = 0;
     }        
 }    
 class Overload_methods 
 {
     public static void main(String args[])
     {
         overload obj = new overload();   
         int a = 2;
         double b = 3.2;
         obj.add(a, a);
         obj.add(b, b);
         System.out.println(obj.x + " " + obj.y);     
     }
}

A. 6 6

B. 6.4 6.4

C. 6.4 6

D. 4 6.4

Answer: Option D


This Question Belongs to Java Program >> Overriding And Overloading

Join The Discussion

Related Questions on Overriding and Overloading