Day 25
Hello!
Defining a method named sum:
It takes two integers as parameters and returns their sum.
Calling the method in main:
The values 5 and 7 are passed, and the result is printed.
*Types of Methods*
Instance Methods:
These are associated with an object and require an object instance to be called.
Example:
Static Methods:
These are called directly using the class name without creating an object.
Example:
تعليقات
إرسال تعليق