Multiple Choice Moderate

QWhich of the following variables has block scope?

ID: #24874 Control flow in programming 11 views
Question Info
#24874Q ID
ModerateDifficulty
Control flow in programmingTopic

Select All That Apply

Tick every correct option, then press Check Answer.

  • A Class-level variable
  • B Instance variable
  • C Method parameter
  • D Local variable
Correct Answer

Explanation

Correct Answer:

(d) Local variable

Explanation:

Local variables exist only inside the block or method where they are declared.

Example:

  
    void test(){
int x=10;
}

Here x exists only inside test().

Share This Question

Challenge a friend or share with your study group.