際際滷

際際滷Share a Scribd company logo
Presented by
MD. TOFAZZAL HOSSAIN
ID NO: 163015003
Department: CSE (Weekend)
Object oriented programming.
Object oriented programming.
 A collection of statements that are grouped together to
perform an operation.
 A method has the following syntax
modifier return_Value_Type Method Name(list of
parameters)
{ // Method body; }
 A method definition consists of a method header and a
method body
Method Name
The actual name of the method.
Method name and the parameter list together
constitute the method signature.
Parameters
This value is referred to as actual parameter or
argument.
The parameter list refers to the type, order, and
number of the parameters of a method.
Method Body
The method body contains a collection of statements that
define what the method does.
 A concept in Java which allows programmer to
declare method with same name but different
behavior.
 Method with same name co-exists in same class but
they must have different method.
 If you have two methods with same name in
one Java class with different method.
 Generally overloaded method in Java has different
set of arguments to perform something based on
different.
public class MethodOverLoading
{
// Method 1
public static int Addition(int a, int b)
{
System.out.println(Method 1 is called);
return a + b;
}
// Method 2
public static int Addition(int a, int b, int c)
{
System.out.println(Method 2 is called);
return a + b + c;
}
}
public static void main(String[] args)
{
int Answer1 = Addition(5, 6);
// In this case Method 1 will be called
System.out.println(Answer 1 =  + Answer1);
int Answer2 = Addition(5, 6, 7);
// In this case Method 2 will be called
System.out.println(Answer 2 =  + Answer2);
}
Method 1 is called
Answer 1 = 11
----------------------------
Method 2 is called
Answer 2 = 18
THANKS
TO
ALL

More Related Content

Object oriented programming.

  • 1. Presented by MD. TOFAZZAL HOSSAIN ID NO: 163015003 Department: CSE (Weekend)
  • 4. A collection of statements that are grouped together to perform an operation. A method has the following syntax modifier return_Value_Type Method Name(list of parameters) { // Method body; } A method definition consists of a method header and a method body
  • 5. Method Name The actual name of the method. Method name and the parameter list together constitute the method signature. Parameters This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a method.
  • 6. Method Body The method body contains a collection of statements that define what the method does.
  • 7. A concept in Java which allows programmer to declare method with same name but different behavior. Method with same name co-exists in same class but they must have different method.
  • 8. If you have two methods with same name in one Java class with different method. Generally overloaded method in Java has different set of arguments to perform something based on different.
  • 9. public class MethodOverLoading { // Method 1 public static int Addition(int a, int b) { System.out.println(Method 1 is called); return a + b; } // Method 2 public static int Addition(int a, int b, int c) { System.out.println(Method 2 is called); return a + b + c; } }
  • 10. public static void main(String[] args) { int Answer1 = Addition(5, 6); // In this case Method 1 will be called System.out.println(Answer 1 = + Answer1); int Answer2 = Addition(5, 6, 7); // In this case Method 2 will be called System.out.println(Answer 2 = + Answer2); }
  • 11. Method 1 is called Answer 1 = 11 ---------------------------- Method 2 is called Answer 2 = 18