3. Assignments Flashcards
What are the values in an array of objects or primitives, when the respective array is instantiated ?
Objects within the array are not instantiated automatically, but all the references get the default value of null. Primitives in an array also get default values.
Which variables have default values and which not ?
Instance variables are always initialized with a default value.
Local/automatic/method variables are never given a default value. If you attempt to use one before initializing it, you’ll get a compiler error.
What is shadowing ?
Shadowing occurs when two variables with different scopes share the same name. This leads to hard-to-find bugs and hard-to-answer exam questions.
How you can run Garbage Collection ?
Only the JVM decides when to run the GC; you can only suggest it.