Core Java - Interview Questions and Answers for 'Overloading' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Overloading' - 17 question(s) found - Order By Newest

Very Frequently asked to fresh graduates and less experienced. Favorite question in Walk in drives. Frequently asked in Indian Services companies.
  Q1. Difference between Overloading and Overriding ?Core Java
Ans. Overloading - Similar Signature but different definition , like function overloading.

Overriding - Overriding the Definition of base class in the derived class.

  Sample Code for overloading

  Sample Code for overriding

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops   overloading   overriding   oops concepts   basic interview question   overloading vs overriding     Asked in 86 Companies      basic        frequent

Try 1 Question(s) Test


 Q2. Any real life example of Overloading and Overridding ?
Ans. All members of a family share a common last name and thats how outsiders recognize them, but to recognize individual team members , we need an overloaded name and hence we use First Name along with Last Name to uniquely identify.

Some members of a family have a Nick Name as the real name is very long or hard to call. So the Nick name overrides the Original Name in certain circumstances.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     overloading  overriding     Asked in 2 Companies


  Q3. Can we overload main method in Java ?Core Java
Ans. Yes, but the overloaded main methods without single String[] argument doesn't get any special status by the JVM. They are just another methods that needs to be called explicitly.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   main method   overloading   yes-no     Asked in 6 Companies      intermediate        frequent


Recently asked in Capital One.
 Q4. What will happen if we call perform(null) ?

public void perform(Object obj) {
System.out.println("Object");
}

public void perform(Integer int) {
System.out.println("Integer");
}
Core Java
Ans. compiler will throws error as ambiguous methods

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     overloading   method overloading     Asked in 1 Companies      intermediate


 Q5. Does java supports operator overloading ?Core Java
Ans. No

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     operator overloading     Asked in 1 Companies      basic


 Q6. Can we overload abstract methods ?Core Java
Ans. Yes

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     overloading  abstract methods  overloading abstract methods


 Q7. How does java identifies which method to be called in method overriding or runtime polymorphism, when both methods share the same name and signature ? Core Java
Ans. Java identifies the method to be called at runtime by the object that is being referenced.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     polymorphism  object oriented programming (oops)  oops concepts  overloading  overriding      basic


 Q8. Can we overload constructors ?
Ans. Yes.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops   constructors   overloading   yes-no   basic interview question


 Q9. How is static and dynamic polymorphism achieved in Java ?Core Java
Ans. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     static polymorphism  object oriented programming (oops)  oops concepts   dynamic polymorphism  object oriented programming (oops)  oops concepts   polymorphism  object oriented programming (oops)  oops concepts   overloading   overriding   broadridg     Asked in 1 Companies      basic        frequent


 Q10. Write code for constructor overloadingCore Java
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=965

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     constructor overloading  code  coding     Asked in 2 Companies      basic


 Q11. Which of the two - compile time and run time polymorphism - requires signature of the method to be different ?Core Java
Ans. runtime polymorphism or method overriding doesn't require method name and signature to be different whereas compile time polymorphism or method overloading requires method name to be same but the signature to be different.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     polymorphism  object oriented programming (oops)  oops concepts  overloading  overriding      basic


 Q12. Can we override the overloaded methods too ?Core Java
Ans. Yes. Both concepts are independent of each other. Overriding depends on the methods with same name and signature whereas Overloading on same name but with different signatures. All definitions of an overloaded method can be individually overridden in the derived class.

For example -

Class A has overloaded methods "public void myMethod(String str)" and "public void myMethod(int x)"

We can have derived class ClassB extends ClassA and hence can override both methods myMethod(String str) and myMethod(int x) in ClassB

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     overloading  overriding     Asked in 1 Companies


 Q13. Is this constructor overloading ?

What is the difference between the 2 methods in Java ?

Class BuggyBread {

BuggyBread(){
}
void BuggyBread(int x){
}
}
Core Java
Ans. No, first method is a constructor whereas the second method is just a normal method. There is no way a constructor can be called explicitly and hence all explicit calls to BuggyBread() would result in compilation error.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     constructor  overloading


 Q14. Which method will get called if we call it as method(1)

void method(int x ){};
void method(int... x){};
Core Java
Ans. Though the call an be bind to either of these but in this case, 1st method will get priority and hence will be called.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     var args  method  function  overloading  scjp  ocjp


 Q15. Why doesn't java support operator overloading ?Core Java
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     operator overloading


 Q16. in the following class:
class A {
void methoda(Object o) {
Sysout("Object");
}

void methoda(String s) {
Sysout("String");
}

public static void main(String []args) {
A a = new A();
a.methoda(null);
}
}

what will be printed?
Core Java
Ans. String

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     Code  Coding  method overloading     Asked in 1 Companies


 Q17. Can we have more than two constructors in a class ?Core Java
Ans. Yes, through constructor overloading

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     constructor overloading


 Q18. The following code is an example of

public class Car extends Vehicle{
   int x;

   Car(int y){
      x = 5;
   }

   Car(){
      this(5);
   }
}
Core Java
a. Constructor Overloading
b. Constructor Chaining
c. Both Constructor Overloading and Chaining
d. None of above

Ans.c. Both Constructor Overloading and Chaining

 Q19. Which of following cannot be overloaded ?Core Java
a. Constructors
b. Main Method
c. Final Methods
d. All of above can be overloaded

Ans.d. All of above can be overloaded


Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: