Posts

Showing posts with the label class variable java

Scope of a variable in java जावा में वेरिएबल का कार्यक्षेत्र

In Java, the scope of a variable refers to the region in a program where the variable is recognized and accessible. Variables in Java can be categorized based on their scope into three main types: जावा में वेरिएबल का कार्यक्षेत्र उस हिस्से को कहा जाता है जहाँ वेरिएबल मान्य और उपयोग योग्य होता है। जावा में वेरिएबल के कार्यक्षेत्र को तीन प्रमुख वर्गों में बांटा गया है– 1️⃣ Local Variable (लोकल वेरिएबल) English: Declared and used only inside a method or a block {} . Scope is limited to that method or block. Dies as soon as the control exits the method. Java does not allow same-name variables in nested blocks unlike C/C++. Hindi: यह किसी मेथड या ब्लॉक {} के अंदर ही घोषित और उपयोग किए जाते हैं। इनका कार्यक्षेत्र उसी मेथड या ब्लॉक तक सीमित होता है। जैसे ही कंट्रोल बाहर जाता है, यह समाप्त हो जाते हैं। जावा में नेस्टेड ब्लॉक्स में एक ही नाम के दो वेरिएबल नहीं बनाए जा सकते हैं। 2️⃣ Instance Variable (इंस्टैंस वेरिएबल) English: Declared inside a class but...