Select chapter



basics (7.papers)
constructors (1.papers)
packages (1.papers)
inheritance (7.papers)
misc (3.papers)
exceptions (5.papers)
threads (4.papers)
overloading (1.papers)
jsp (3.papers)
servlets (9.papers)
jdbc (2.papers)
util (1.papers)
xml (2.papers)
IO stream (3.papers)
Hide

Sponsored Links


  

java overloading interview questions and answers

1
In below programs which one is function overloading?
  1. class Math{
      public void add(int i, int j)
      {
        S.o.pln("added.."+(i+j));
      }
      public void add(int j, int i)
      {
        S.o.pln("added.."+(i+j));
      }
    }
  2. class Math{
      public void add(int i, int j)
      {
        S.o.pln("added.."+(i+j));
      }
      public void add(int i, int j)
      {
        S.o.pln("added.."+(i+j));
      }
    }
  3. class Math{
      public void add(int i, int j)
      {
        S.o.pln("added.."+(i+j));
      }
      public void add(int i)
      {
        S.o.pln("added.."+(i+i));
      }
    }
  4. class Math{
      public void add(int i, int j)
      {
        S.o.pln("added.."+(i+j));
      }
      public int add(int i, int j)
      {
        S.o.pln("added.."+(i+j));
      }
    }
Show Answer
Share Facebook gmail Twitter
2
Method overloading in java is static polymorphism or dynamic polymorphism?
  1. Dynamic polymorphism
  2. Static polymorphism
  3. both are true
  4. none
Show Answer
Share Facebook gmail Twitter
3
Difference between overloading and overriding?
  1. overloading means multiple functions having same name with either different number of arguments or different type of arguments or different order of arguments in the same class. Overriding means two classes(one base class and one derived class) having same function with same signature and same return type.
  2. overloading is static polymorphism. Overriding is dynamic polymorphism.
  3. overloading always happens with in the same class, where overriding happens in inheritance concept where derived classes will have same method as in the base class with same signature and same return type.
  4. all are true.
Show Answer
Share Facebook gmail Twitter
4
What is method overloading?
  1. Having multiple methods  with same name but different signatures in a class, is called as method overloading. 
  2. Having the same method with same name and signature in super class and sub class is called as method overriding.
  3. both are correct.
  4. none
Show Answer
Share Facebook gmail Twitter
5
What is constructor overloading?
  1. Having mutiple constructor with different signature in a class is called as constructor overloading. 
  2. It is not possible to overload constructors in java.
  3. option2 is correct because constructors are special functions in java.
  4. none
Show Answer
Share Facebook gmail Twitter
Read more papers :