To be able to access a variable declared in one file/class from another file/class you need to declare that variable as "public".
Doing this is a very bad coding practice because exposing a variable of a class to be available publicly to other classes is totally against the Java object oriented concepts of Encapsulation and Data hiding. So, preferably you shouldn't be doing this.
However, a better way to do this is, declare the variable as private and have public accessor methods through which you can access this variable. This will ensure that your data is protected even if it is available outside the class
You declare it extern in the file you want to access it from. In the file that it is declared, declaring it at file scope automatically makes it visible to all files in the linkage scope.
file1.c
extern int a;
...
... use a
file2.c
int a
...
extern
Global Varible: The variable which is declared as "Global" one : having the preveleges to use and access that variable in any class and object( means any where in the program) just like PUBLIC keyword in OOPS concepts. Static Variable : If we declare a variable as Static , then it wont have the permission to access that variable through out the program and u have to use it inside the class or object which u declared itself. All the Best Annapurna
If you are talking about a class in Java, a variable encapsulated by a class is called an instance variable b/c everytime you create an object with that class, each object has its own set of the variables declared.
Register variables are stored in register of microprocessor/micro-controller. The read/write access to register variable is the fastest because CPU never need any memory BUS operation to access these variable. Auto variable are stored in stack thus access are much slower. Auto variable can be converted to register by using register keyword before it. It has platform specific limitation. Register variable will work only if free registers are available to hold the variable for a function scope. In case of Microprocessor or microcontrollers having very less number of general purpose registers will never take register variable even if we declare it as register.
A reference variable is used to refer to or give access to an object. A reference variable is declared to be of a particular type and that type can not be altered.
Because, the keyword static signifies the fact that the method or variable that is qualified using the static keyword is not attached to any object of the class. Therefore we cannot instantiate the class and use the object to reference to access it. The only option we have is to use the class name to directly access them
r+ is the keyword
The keyword public is an access specifier. A variable or a method that is declared public is publicly accessible to any member of the project. Any class or method can freely access other public methods and variables of another class.
An access specifier is a keyword applied to a variable, or method, which indicates which parts of the program are permitted to access it.
Threads are not volatile. The volatile is a keyword that is used while having multiple threads in a Java Program. This keyword is used when multiple threads access a particular variable but still it is not mandatory to synchronize or prevent access to that variable.
An access modifier is another name for an access specifier, which in object-orientated software is a keyword applied to a variable which indicates which other parts of the programme are permitted to access it.
Global Varible: The variable which is declared as "Global" one : having the preveleges to use and access that variable in any class and object( means any where in the program) just like PUBLIC keyword in OOPS concepts. Static Variable : If we declare a variable as Static , then it wont have the permission to access that variable through out the program and u have to use it inside the class or object which u declared itself. All the Best Annapurna
No. Variables declared inside a scriptlet are like method local variables which are not accessible outside the scriptlet/method.
If you are talking about a class in Java, a variable encapsulated by a class is called an instance variable b/c everytime you create an object with that class, each object has its own set of the variables declared.
Register variables are stored in register of microprocessor/micro-controller. The read/write access to register variable is the fastest because CPU never need any memory BUS operation to access these variable. Auto variable are stored in stack thus access are much slower. Auto variable can be converted to register by using register keyword before it. It has platform specific limitation. Register variable will work only if free registers are available to hold the variable for a function scope. In case of Microprocessor or microcontrollers having very less number of general purpose registers will never take register variable even if we declare it as register.
The keyword "friend" allows a function or variable to have access to a protected member inside a class.
A reference variable is used to refer to or give access to an object. A reference variable is declared to be of a particular type and that type can not be altered.
Because, the keyword static signifies the fact that the method or variable that is qualified using the static keyword is not attached to any object of the class. Therefore we cannot instantiate the class and use the object to reference to access it. The only option we have is to use the class name to directly access them