Page 39 - CITS - CSA - TP (Volume 2) - Hindi
P. 39
कं ूटर सॉ वेयर ए ीके शन - CITS
अ ास 83: लोकल, इं स और ास वै रएबल बनाएं और उनका उपयोग कर (Create and use
Local, Instance and Class variables)
उ े
इस अ ास के अंत म , आप िन िल खत काय कर सक गे :
• िविभ लोकल, इं स और ास वे रएब के उपयोग को जानना
• िविभ लोकल, इं स और ास वे रएब का उपयोग करके Java डेवलप करना
• Java ो ाम के प रणाम को संकिलत करना, िन ािदत करना और स ािपत करना।
आव कताएं (Requirements)
उपकरण/साम ी
• PC/लैपटॉप के साथ िवंडो OS
• JDK सॉ वेयर
ि या (Procedure)
टे एिडटर (िवजुअल ू िडयो/सबलाइम/नोटपैड)
टा 1: लोकल वे रएब उदाहरण
public class VariableExample1 {
public static void main(String[] args) {
calculateSum(5, 7);
}
static void calculateSum(int a, int b) {
// Local variable: sum
int sum = a + b;
System.out.println(“Sum: “ + sum);
}
}
आउटपुट:
टा 2: इं स वे रएब उदाहरण
public class VariableExample2 {
public static void main(String[] args) {
// Create an instance of the Student class
Student myStudent = new Student();
25

