Method :
- Set of instructions for achieving a specific-tasks - with a name (or) with or without arguments (or) with or without return datatype.
- If we do not return any value, we should mention “void” before method name.
- Modularity
- Code Reusability
employee1.enquiry();
employee1.enquiry(1234);
}
private void enquiry(int accNo) {
System.out.println("Balance enquiry");
}
private void enquiry() {
System.out.println("General enquiry");
}
Same method name with different number of arguments is called Method overloading.
employee1.enquiry(15.3f);
private void enquiry(float gold) {
System.out.println("Gold rate please");
Same method name with different type of arguments is also known as Method overloading.
Another name called Compile time polymorphism.
Top comments (0)