Detailed Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem#JAVA#3875

Problem Statement - Data default values Viva-question

Why do we need to initialise local variables when we have default values specified for all primitive data types.

Solution

Click to open popup

Solved Problem Understanding

Java does not allow default values for local variables so that the programmer is forced to use the known values of variables and accidentally processing the incorrectly value is reduced. For static and instance variables they may have to be used by many discrete methods so default values are useful.