Can we programatically login to Yahoo services with our ID, send instant message, use webcam service and so on directly from our program?
Yahoo Messenger has a plug-in SDK. It is hard to know if this meets your needs, since you are not very clear.
If you are looking to access Yahoo messenger services through Java for instance, you could try an API.
You could look at libpurple, although I'm not sure what its webcam support is like.
Since you're not very clear about what you want to achieve, the two most likely answers:
You want to write some form of IM bot. For that you would need an API to the Yahoo Messenger network, in which case your best bet is something like libpurple, jYMSG, or libyahoo. This will allow you to login, and send/receive messages to/from contacts, and theoretically do anything the regular Yahoo Messenger client can do.
You could also directly communicate with the Yahoo servers using the Yahoo Messenger Protocol, which is unofficially documented here, a good resource on this here. This will be a lot of work, and you're probably better using libpurple etc.
Control the Yahoo Messenger client itself. For this, you are probably best writing whatever you wish to do as a plugin, for which there is an API.
Alternatively, On OS X you could use AppleScript to control the interface (by scripting button presses/text-input, as described here). On Windows, you could use AutoHotkey to do similar things.