22.2k views
1 vote
is when you have a local variable or parameter variable with the same name as a field and this means that the name of tire field is hidden by the name of the local variable or parameter variable. Select one: widening narrowing shadowing dismissing tagging Clear my choice A import statement tells the compiler to import all of the classes in a package and is sometimes referred to as a "lazy import". Select one: wildcard import asterisk import star import import all Clear my choice

1 Answer

4 votes

Short answerThe answer for the first question is Shadowing.The answer for the second question is Wildcard import.100 wordsWhen you have a local variable or parameter variable with the same name as a field, it is called Shadowing. This means that the name of the field is hidden by the name of the local variable or parameter variable. When this happens, the local variable or parameter variable takes precedence over the field. This can cause confusion and lead to errors in your program if you're not careful. To avoid this issue, you should always choose different names for your local variables and parameter variables than your field names. This will ensure that there is no ambiguity in your code and that it is clear which variable you are referring to at any given time. An import statement that tells the compiler to import all of the classes in a package is called a Wildcard import. It is sometimes referred to as a "lazy import" because it saves you from having to list out every class that you want to import individually. This can be a time-saver, especially when you're working with large packages that contain many classes. However, it can also make your code less clear and more difficult to read, so you should use it sparingly and only when it makes sense.ConclusionTo conclude, Shadowing is the term used when a local variable or parameter variable has the same name as a field, and Wildcard import is an import statement that tells the compiler to import all of the classes in a package.

User Moamen
by
8.3k points

No related questions found