Page 279 - COPA VOL II of II - TP -Punjabi
P. 279
ਟਾਸਕ 1 : Java ਿਭੱਚ ਿੇ੍ੀਏਬਲ
• ਿੇ੍ੀਏਬਲ ਘੋਸ਼ਭਤ ਕ੍ਨਾ (ਬਣਾਉਣਾ)
ਸੰਟੈਕਸ : -
SOURCE CODE
public class VariableExample{
int myVariable;
static int data = 30;
public static void main(String args[]){
int a = 100;
VariableExample obj = new VariableExample();
System.out.println(“Value of instance variable myVariable: “+obj.myVariable);
System.out.println(“Value of static variable data: “+VariableExample.data);
System.out.println(“Value of local variable a: “+a);
}
}
Fig 1
IT & ITES - COPA - (NSQF ਸੋਧੇ - 2022) - ਅਿਭਆਸ 1.39.06 265