212). What is the process of defining two or more methods within same class that have same name but different parameters declaration?

[A]method overloading
[B]method overriding
[C]method hiding
[D]none of the mentioned

Show Answer

214). Which of these is correct about passing an argument by call-by-value process?

[A]Copy of argument is made into the formal parameter of the subroutine
[B]Reference to original argument is passed to formal parameter of the subroutine
[C]Copy of argument is made into the formal parameter of the subroutine and changes made on parameters of subroutine have effect on original argument
[D]Reference to original argument is passed to formal parameter of the subroutine and changes made on parameters of subroutine have effect on original argument

Show Answer

216). What will be the output of the following Java code?
class San
{
 public void m1 (int i,float f)
 {
  System.out.println(" int float method");
 }
 
 public void m1(float f,int i);
  {
  System.out.println("float int method");
  }
 
  public static void main(String[]args)
  {
    San s=new San();
        s.m1(20,20);
  }
}

[A]int float method
[B]float int method
[C]compile time error
[D]run time error

Show Answer

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

[A]5
[B]6
[C]7
[D]8

Show Answer

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

[A]6
[B]7
[C]8
[D]9

Show Answer

219). 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

Show Answer

220). What will be the output of the following Java code?
    class test 
    {
        int a;
        int b;
        void meth(int i , int j) 
        {
            i *= 2;
            j /= 2;
        }          
    }    
    class Output 
    {
        public static void main(String args[])
        {
            test obj = new test();
	    int a = 10;
            int b = 20;             
            obj.meth(a , b);
            System.out.println(a + " " + b);        
        } 
    }

[A] 10 20
[B]20 10
[C] 20 40
[D]40 20

Show Answer

221). What will be the output of the following Java code?
    class test 
    {
        int a;
        int b;
        test(int i, int j) 
        {
            a = i;
            b = j;
        }
        void meth(test o) 
        {
            o.a *= 2;
            O.b /= 2;
        }          
    }    
    class Output 
    {
        public static void main(String args[])
        {
            test obj = new test(10 , 20);
            obj.meth(obj);
            System.out.println(obj.a + " " + obj.b);        
        } 
    }

[A] 10 20
[B]20 10
[C]20 40
[D]40 20

Show Answer