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

0

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");
}
}
Posted by: Guest on March-29-2022

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language