Skip to content
Related Articles

Related Articles

Java | final keyword | Question 3

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 28 Jun, 2021

class Main {
 public static void main(String args[]){
    final int i;
    i = 20;
    i = 30;

(A) 30
(B) Compiler Error
(C) Garbage value
(D) 0

Answer: (B)

Explanation: i is assigned a value twice. Final variables can be assigned values only one. Following is the compiler error “ error: variable i might already have been assigned”

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!