The correct command sequence to create VLAN 20 and assign it to an interface is:
A. Switch(config)#vlan 20
Switch(config)#Interface gig x/y
Switch(config-if)#switchport access vlan 20
Reasoning
Step 1: vlan 20 – This command enters VLAN configuration mode and creates the VLAN in the switch's database.
Step 2: interface gig x/y – This enters the configuration mode for the specific physical interface.
Step 3: switchport access vlan 20 – This command assigns the interface to VLAN 20. On most modern Cisco switches, this command also implicitly sets the port to access mode if not already configured, though it is best practice to precede it with switchport mode access.
Why the others are incorrect:
B: You cannot create a VLAN by typing the vlan command while inside a physical interface's configuration mode (config-if).
C, D, and E: These options use interface vlan 20, which creates a VLAN Interface (a Layer 3 Switch Virtual Interface or SVI). This is used for routing and management, not for assigning a physical switch port to a VLAN. Furthermore, switchport commands are Layer 2 commands and cannot be applied to an SVI.