I heard you can exercise your eyes by seeing something close and seeing something far away. Is this effective?

Somewhat. If you have certain near vision problems (convergence insufficiency, for example), there is benefit from practicing with focusing on an object like a pencil tip as you bring it as close as you can. If the difficulty arises from the need to wear prescription glasses or the nead to wear reading glasses, eye exercises do not really work. Also, be wary of ads for costly vision exercise "programs".
Yes. It is called pencil pushups and can help to strenghten the muscles that focus up close. This has to be done regularily but does help some.