-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticKeyword3.java
More file actions
44 lines (37 loc) · 851 Bytes
/
Copy pathStaticKeyword3.java
File metadata and controls
44 lines (37 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Demo1
{
static int a;
static int b;
int m; // object varibale , instance , fields
int n;
static
{
a=10;
b=20;
System.out.println("control in static block");
}
{
m=100;
n=200;
System.out.println("Control in non static block");
}
static void disp1()
{
System.out.println("Value of static variable " + a);
System.out.println("Value of Static variable " + b);
}
void disp2()
{
System.out.println("Value of non static variable or instance variable " + m);
System.out.println("Value of non Static variable or instance variable " + n);
}
}
public class StaticKeyword3
{
public static void main(String[] args)
{
Demo1 d1 = new Demo1();
d1.disp1();
d1.disp2();
}
}