Solved

The Variable Name Perfect in the Method MyFun in the Code

Question 15

Multiple Choice

The variable name perfect in the method myFun in the code snippet below is used as both a parameter variable and a variable in a nested block within the method. Which statement about this situation is true?
Public static int myFun(int perfect)
{
{
Int perfect = 0;
Return ((perfect - 1) * (perfect - 1) ) ;
}
}


A) This multiple declaration of the variable perfect will not compile because the scopes overlap
B) While this is legal and will compile in Java, it is confusing
C) Because the scopes of these variables do not overlap, there is no problem
D) This situation rarely occurs and the compiler always issues a warning

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents