-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticdemo.java
More file actions
58 lines (42 loc) · 1004 Bytes
/
Copy pathStaticdemo.java
File metadata and controls
58 lines (42 loc) · 1004 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.lang.*;
class Demo
{
public int i;
public int j;
public static int k;
static
{
System.out.println("Inside static block");
k=11;
}
public Demo()
{
this.i=0;
this.j=0;
System.out.println("Inside default constructor");
}
public void fun()
{
System.out.println("Inside non-static fun");
System.out.println(this.i);
System.out.println(this.j);
System.out.println(this.k);
}
public static void gun()
{
System.out.println("Inside static gun");
System.out.println(k);
}
}
class Staticdemo
{
public static void main(String a[])
{
Demo.gun();
Demo obj; //it is just a refetence
obj=new Demo(); //actual memory allocated
/* obj.fun();
System.out.println(obj.i);
System.out.println(obj.j); */
}
}