1.HowcouldJavaclassesdirectprogrammessagestothesystemconsole,buterrormessages,saytoafile?TheclassSystemhasavariableoutthatrepresentsthestandardoutput,andthevariableerrthatrepresentsthestandarderrordevice.Bydefault,theybothpointatthesystemconsole.Thishowthestandardoutputcouldbere-directed:Streamst=newStream(newFileOutputStream("techinterviews_com.txt"));System.setErr(st);System.setOut(st);2.What’sthedifferencebetweenaninterfaceandanabstractclass?Anabstractclassmaycontaincodeinmethodbodies,whichisnotallowedinaninterface.Withabstractclasses,youhavetoinherityourclassfromitandJavadoesnotallowmultipleinheritance.Ontheotherhand,youcanimplementmultipleinterfacesinyourclass.3.Whywouldyouuseasynchronizedblockvs.synchronizedmethod?Synchronizedblocksplacelocksforshorterperiodsthansynchronizedmethods.4.Explaintheusageofthekeywordtransient?Thiskeywordindicatesthatthevalueofthismembervariabledoesnothavetobeserializedwiththeobject.Whentheclasswillbede-serialized,thisvariablewillbeinitializedwithadefaultvalueofitsdatatype(i.e.zeroforintegers).5.Howcanyouforcegarbagecollection?Youcan’tforceGC,butcouldrequestitbycallingSystem.gc().JVMdoesnotguaranteethatGCwillbestartedimmediately.6.Howdoyouknowifanexplicitobjectcastingisneeded?Ifyouassignasuperclassobjecttoavariableofasubclass’sdatatype,youneedtodoexplicitcasting.Forexample:Objecta;Customerb;b=(Customer)a;Whenyouassignasubclasstoavariablehavingasupeclasstype,thecastingisperformedautomatically.7.What’sthedifferencebetweenthemethodssleep()andwait()Thecodesleep(1000);putsthreadasideforexactlyonesecond.Thecodewait(1000),causesawaitofuptoonesecond.Athreadcouldstopwaitingearlierifitreceivesthenotify()ornotifyAll()call.Themethodwait()isdefinedintheclassObjectandthemethodsleep()isdefinedintheclassThread.8.CanyouwriteaJavaclassthatcouldbeusedbothasanappletaswellasanapplication?Yes.Addamain()methodtotheapplet.9.What’sthedifferencebetweenconstructorsandothermethods?Constructorsmusthavethesamenameastheclassandcannotreturnavalue.Theyareonl...