UrbanPro
true

Take BTech Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Overloading in JAVA

Swati S.
19/05/2020 0 0

When a class contains more than one method with the same method name but different argument types, then it is called Overloading.

Methods are said to be Overloaded methods.

Also, know as Compile time binding or Early binding.

The compiler takes care of overloaded methods and decides according to the signature which way is to be invoked.

Eg:    class Display

         {

        public void show( int b) //1

         {System.out.println(b);}

        public void  show(String s) //2

        {System.out.println(s);}

          public static void main(String args[ ])

          {

        Display d = new Display();

        d.show(2);//1 method invoked

        d.show("Swati");//2 method invoked

       d.show( 10.5f)/*in 3 invocation

    1  method gets invoked though show(float ) not present*/

}

}

1 &2  are overloaded methods in class Display.During a method call compiler first searches for exactly matched method calls in class.3 invocation  compiler actually searches for show(float f)  but it is not found.So it again searches for the method having argument that can be promoted into float and encounters 1 method.As we all know int can be converted into float.This is called Automatic argument promotion.

 

 

Output of program

Swati

10.5

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Viscometers
The measurement of viscosity is a large and complicated subject. The principles rely on the resistance to flow or the resistance to motion through a fluid. Many of these are covered in British Standards...

Control System Block Diagram Reduction
Block Diagram Reduction Method Step 1: Initial Setup In the original block diagram: - You have blocks G1 and G2 in series in the forward path. - These feed into a summing point with a feedback loop containing...

How to Study and Learn Better: Tips to Students!
Find out where, when and how you learn best: By taking notes? Reading one book at a time? Through all-out effort? Study groups? Organise your time and the place to study according to that. Take breaks. Check...

Structure And Function
A computer is a complex system; contemporary computers contain millions of elementary electronic components.How,then,can one clearly describe them? The key is to recognize the hierarchical nature of most...

Java Training Syllabus
Learn JAVA-J2EE Syllabus Core Java - Syllabus aligned to OCA Exam - JDK 8 Object-Oriented Programming (OOPS) concepts: Programming Languages Object Oriented Programming Classes & Objects Pillars...
X

Looking for BTech Tuition Classes?

The best tutors for BTech Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BTech Tuition with the Best Tutors

The best Tutors for BTech Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more