Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
docu...
Typing Speed
Week

Target Achieved

1

40

21

2

40

23

3

40

27
Jobs Applied
Week

Company

Designation

Applied Date

Current Status

1

Advent
software

Sr. Application Engineer

28-8-...
Method overloading and constructor overloading
in JAVA
Muhammed Noufal V T
muhammednoufalvt@gmail.com
www.facebook.com/vtn...
What is Method
• A Java method is a collection of statements that are grouped
together to perform an operation
• A class c...
Method Overloading
• Two or more methods within the same class that share the same
name, but with different parameter decl...
Example
•
{

public class example_1

void square(int p1, int p2)
int n1;
int n2;
example_1()
{
n1 = 10;
n2 = 20;
}
void sq...
Constructor
•
•
•
•

Special type of method
A constructor initialize an object immediately upon creation
Name of construct...
Constructor Overloading
• Constructors are methods that can be overloaded, just like any
other method in a class.
• Constr...
class Point
{
int x;
int y;
Point(int a, int b)
{
x = a;
y = b;
}}
class Circle
{
int originX;
int originY;
int radius;
Ci...
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550

Start up Vil...
Method overloading and constructor overloading in java
Nächste SlideShare
Wird geladen in …5
×

Method overloading and constructor overloading in java

15.559 Aufrufe

Veröffentlicht am

Method overloading and constructor overloading in java

Veröffentlicht in: Bildung, Technologie, News & Politik
  • Als Erste(r) kommentieren

Method overloading and constructor overloading in java

  1. 1. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  2. 2. Typing Speed Week Target Achieved 1 40 21 2 40 23 3 40 27
  3. 3. Jobs Applied Week Company Designation Applied Date Current Status 1 Advent software Sr. Application Engineer 28-8-2013 Short listed 2 Alcatel-lucent Software Engineer 30-8-2013 Waiting 3 Intel info group System Engineer 6-9-2013 Waiting
  4. 4. Method overloading and constructor overloading in JAVA Muhammed Noufal V T muhammednoufalvt@gmail.com www.facebook.com/vtnoufalvt twitter.com/noufalurnappy in.linkedin.com/pub/muhammed-noufal 9744003056
  5. 5. What is Method • A Java method is a collection of statements that are grouped together to perform an operation • A class can contain any number of methods. • Methods can be with parameter and without parameter. • The parameter in a method are called type signature.
  6. 6. Method Overloading • Two or more methods within the same class that share the same name, but with different parameter declarations (type signatures). • The process is referred to as method overloading. • Overloading methods demonstrate the concept of polymorphism. • Overloaded methods may have different return types. • When java encounters a call to an overloaded method, it simply executes the version of the method whose parameters match the arguments used in the call.
  7. 7. Example • { public class example_1 void square(int p1, int p2) int n1; int n2; example_1() { n1 = 10; n2 = 20; } void square() { System.out.println("The Square is " + n1 * n2); } void square(int p1) { n1 = p1; System.out.println("The Square is " + n1 * n2); } { n1 = p1; n2 = p2; System.out.println("The Square is " + n1 * n2); } public static void main(String args[]) { example_1 obj1 = new example_1(); obj1.square(); obj1.square(4); obj1.square(7,8); } }
  8. 8. Constructor • • • • Special type of method A constructor initialize an object immediately upon creation Name of constructor must be same as name of Class Once defined, the constructor is automatically called immediately after the object is created before the new operator compleates • They do not specify any return type not even void
  9. 9. Constructor Overloading • Constructors are methods that can be overloaded, just like any other method in a class. • Constructors having the same name with different parameter list is called constructor overloading.
  10. 10. class Point { int x; int y; Point(int a, int b) { x = a; y = b; }} class Circle { int originX; int originY; int radius; Circle() { originX = 5; originY = 5; radius = 3; } Circle(int x1, int y1, int r) { originX = x1; originY = y1; radius = r; } Example Circle(Point p, int r) { originX = p.x; originY = p.y; radius = r; } void display() { System.out.println("--Center at " + originX + " and " + originY); System.out.println("Radius = " + radius); } public static void main(String args[]) { Circle c1 = new Circle(); Circle c2 = new Circle(10,20,5); Circle c3 = new Circle(new Point(15,25),10); c1.display(); c2.display(); c3.display(); }}
  11. 11. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550

×