1.

What is blank or uninitialized final variable in Java

Answer»

A final variable in Java is a special type of variable that can only be assigned a value one TIME, either at declaration time or at some other time.

A final variable that is not assigned a value at declaration time is known as a blank or uninitialized final variable. In other words, this variable is not initialized at its declaration time. An EXAMPLE is given as follows:

final int val;    // This is a blank final variable val = 6;

A program that demonstrates a blank or uninitialized final variable in Java is given as follows:

class Demo {    final int NUM;    Demo(int NUM1)    {        num = num1;    } } public class Main {    public static void main(String args[])    {        Demo obj = new Demo(87);        System.out.println("Value of num is: " + obj.num);    } }

The OUTPUT of the above program is as follows: 

Value of num is: 87


Discussion

No Comment Found