Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Implement the static keyword – static variable, static block, static function and static class with following conditions

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
// Java program demonstrate execution of static blocks and variables
 
import java.util.*;
 
public class VariableExample
{
// static variable
static int j = n();
 
// static block
static {
System.out.println("Inside the static block");
}
 
// static method
static int n() {
System.out.println("from n ");
return 20;
}
 
// static method(main !!)
public static void main(String[] args)
{
System.out.println("Value of j : "+j);
System.out.println("Inside main method");
}
}
Source by www.edureka.co #
 
PREVIOUS NEXT
Tagged: #Implement #static #keyword #static #static #static #function #static #class #conditions
ADD COMMENT
Topic
Name
4+2 =