PRACTICAL1
PRACTICAL1
STATIC VARIABLE IN C:
In C programming, the concept of a static variable has a few different
meanings depending on where and how it is used. Let's explore the two
main uses of static variables in C:
```c
#include <stdio.h>
void increment() {
count++;
int main() {
return 0;
In this example, the `count` variable is declared as `static int count = 0;`
inside the `increment` function. Unlike normal local variables, `count`
retains its value between successive calls to `increment()`. Therefore,
each time `increment()` is called, `count` is incremented and its updated
value is printed.
### 2. Static Variables outside Functions
**file1.c**
#include <stdio.h>
void function1() {
**file2.c**
#include <stdio.h>
void function2() {
### Summary
Method overloading occurs when multiple methods in the same class have
the same name but different parameters. The Java compiler determines
which method to call based on the number and types of arguments
passed to it. Consider this example:
```java
```
In the above code, the `display` method is overloaded with two versions:
one that takes an `int` parameter and another that takes a `String`
parameter. When you call `display(10)` or `display("Hello")`, Java
determines which version of the `display` method to execute based on
the argument type.
```java
class Animal {
@Override
System.out.println("Dog barks");
```
1. **Exact Match**: The compiler looks for an exact match between the
method name and the argument types.
### Conclusion
Understanding call resolution in Java involves knowing how the compiler
selects the correct method or constructor based on the method's name,
argument types, and the context of inheritance (for overriding). Method
overloading and overriding are fundamental concepts in Java
programming that allow you to write more flexible and reusable code by
providing multiple implementations of methods with the same name.