Here I am having a array of 4 elements but the it prints the value as 11 so how does the size has become 11 instead of 4
array set ipname {UART TEST SPI I2C}
set bsize [array size ipname];
puts "$bsize"
The array set (which only makes two elements in your case!) does not remove any existing contents of the array, which must have had between 9 and 11 elements in it previously. If I run your code in a bare tclsh, it prints 2. If I then follow up with parray, it tells me what it did:
% parray ipname
ipname(SPI) = I2C
ipname(UART) = TEST
set bsize [llength [array names ipname]]