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

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



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

Very Frequently asked to fresh graduates and less experienced. Favorite question in Walk in drives.
  Q1. Difference between Overloading and Overriding ?Core Java
Anonymous
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     PC Technology  Cognizant (CTS)  Donlen   hybris Software  RedMane  Allerin Technologies  Gemalto  Allerin Technologies  HCL Technologies  Tata Consultancy (TCS)  Accenture India  Infosys Technologies  Polaris  United Healthcare India  IBM India  Xchanging  American Express  Antra  Flipp  Computer Sciences Corporation (CSC)  Garmin  NetSuite  Donlen  Hudsons Bay  Techlogix  SevOne  Synactive  Oodles Technologies  FDM Group  Marlabs  RedMane Technology  Faichi Solutions  TD  Tech Mahindra  Shutterfly  Luxoft  PC Technology  CCC Information Services  State Farm  Raja Software  Mastek  EPAM  Morgan Stanley  SummitWorks  Sony  Citibank  Emtec  LowerMyBills  Consilience  Xavor  AllState  FasTrak  AmTrust Financial  Walt Disney  Ultramain Systems  International Turnkey Systems  Knoldus Software  CA Technologies  Amdocs  FDM Group  Hybris  Fidelity  United Health Group (UHG)  Bluewhale Solutions  Pegasystems  Revature   Innoplexus  Vanguard  AptSource  Perficient  Grapecity  Subex  QuintilesIMS  NimbleUser  Expeditors Associate  Sapient  HR Cloud  Summitworks  Jabong.com  Kony Labs  Price Waterhouse Coopers (PWC)      basic        frequent

Try 1 Question(s) Test


  Q2. Can we overload main method in Java ?Core Java
Admin
info@buggybread.com
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     The Advisory Board Company  Thomson Reuters  ePace Technologies  PC Technology  PEOL  MilleniumSoft      intermediate        frequent


 Q3. Can we overload constructors ?
Anonymous
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


 Q4. 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   dynamic polymorphism   polymorphism   overloading   overriding     Cognizant (CTS)      basic        frequent


 Q5. 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     Capgemini  Paxcel Technologies      basic


Recently asked in Capital One.
 Q6. 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     CapitalOne      intermediate


 Q7. Any real life example of Overloading and Overridding ?2016-06-13 10:44:01

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


 Q8. Can we overload abstract methods ?Core Java2017-03-01 09:43:18

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


 Q9. Which of the two - compile time and run time polymorphism - requires signature of the method to be different ?Core Java2017-05-02 08:31:29

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  overloading  overriding      basic



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. 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 Java2017-05-02 08:33:52

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  overloading  overriding      basic


 Q11. Can we override the overloaded methods too ?Core Java2017-05-07 16:31:47

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


 Q12. Is this constructor overloading ?

What is the difference between the 2 methods in Java ?

Class BuggyBread {

BuggyBread(){
}
void BuggyBread(int x){
}
}
Core Java2017-05-13 20:05:45

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


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

void method(int x ){};
void method(int... x){};
Core Java2017-05-22 21:32:17

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


 Q14. Why doesn't java support operator overloading ?Core Java2017-06-23 08:15:18

 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


 Q15. 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

 Q16. 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



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: