हिंदी

Differentiate between the pure method and Impure method.

Advertisements
Advertisements

प्रश्न

Differentiate between the pure method and Impure method.

अंतर स्पष्ट करें
Advertisements

उत्तर

Feature Pure Method Impure Method
State Modification Does not modify the original state of the object or any external data. Modifies the state of the object, instance variables, or global variables.
Side Effects Has zero side effects (no changes to files, console output, or database records). Has side effects because it changes data variables or prints output to the environment.
Output Consistency Always returns the exact same output if given the exact same input arguments. May return different outputs for the same inputs if internal or external states change.
Passing Mechanism Typically relies on call by value using primitive data variables. Typically relies on call by reference using object references or arrays.
Common Use Case Case is used for mathematical operations, sorting arrays safely, or checking boolean conditions.

Used for updating an object's profile, saving records, or tracking incrementing IDs.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: User-Defined Methods - Exercises [पृष्ठ ९१]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 3 User-Defined Methods
Exercises | Q 4. (vi) | पृष्ठ ९१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×