Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| |||||||||||
Core Java - Interview Questions and Answers for 'Default value' - 5 question(s) found - Order By Newest | |||||||||||
| |||||||||||
Ans. boolean ---> false byte ----> 0 short ----> 0 int -----> 0 long ------> 0l char -----> /u0000 float ------> 0.0f double ----> 0.0d any object reference ----> null | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   data types   default values | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||
Ans. member variable are loaded into heap, so they are initialized with default values when an instance of a class is created. In case of local variables, they are stored in stack until they are being used. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   jvm   memory management   variables   stack memory   heap memory   default values expert | |||||||||||
| |||||||||||
Ans. The default value of the boolean type is false. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   data type   boolean   initialization   default object construction   default constructor   default value | |||||||||||
Ans. The code will not compile raising an error that the local variable y might not have been initialized. Unlike member variables, local variables are not automatically initialized to the default values for their declared type. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   code   default value | |||||||||||
| |||||||||||
Ans. It will print the garbage value as compiler doesn't provide a default value to local variables. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  local variable  default values basic | |||||||||||
| |||||||||||