InterviewSolution
Saved Bookmarks
| 1. |
Identify the output of the java program and state the reason. |
|
Answer» 1. PUBLIC class InterviewBit2. {3. public STATIC void main(String[] args) {4. FINAL int i;5. i = 20;6. int j = i+20;7. i = j+30;8. System.out.println(i + " " + j);9. }10. } The above code will GENERATE a compile-time error at Line 7 saying - [error: variable i might already have been initialized]. It is because variable ‘i’ is the final variable. And final variables are allowed to be initialized only once, and that was already done on line no 5. |
|