You are on page 1of 10

7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

TCSTechnicalInterviewQuestionsandAnswers

TCSPossibleTechnicalInterviewQuestions|fornewCampusRecruitment

InterviewWithTCS

TheCampus Interview

Thisinterviewusuallytakes45minutestoanhourandmayhaveoneortwointerviewers.Oneinterviewermayfocusonyourcommu
skillsandbackgroundbyaskingbehavioralquestions.Theotherwillfocusonyourtechnicalcapabilities.

The Phone Interview

IfTCSnotcomingtoyourschoolthisfall,andyouhaveprobablysubmittedyourresumeonline.Youlookgreatonpaperandtheywo
discussionwithcandidate.Theywillsetupamutuallyconvenientdateandtimeforyourphoneinterview.Yourinterviewerwillassess
managementskillsandbackgroundbyaskingbehavioralquestions.He/shemayalsoassessyourtechnicalability.Ifthephoneinte
tojoinusforaninpersoninterview.

TCS Technical interview Questions


1.What is your strongest programming language (Java, ASP, C, C++, VB, HTML, C#, etc.)?
Pointtoremember:BeforeinterviewYoushoulddecideyourFavoriteprogramminglanguageandbepreparedbasedonthatquest

2.Differences between C and Java?

1.JAVAisObjectOrientedwhileCisprocedural.
2.JavaisanInterpretedlanguagewhileCisacompiledlanguage.

3.CisalowlevellanguagewhileJAVAisahighlevellanguage.
4.CusesthetopdownapproachwhileJAVAusesthebottomupapproach.

5.PointergobackstageinJAVAwhileCrequiresexplicithandlingofpointers.
6.TheBehindthescenesMemoryManagementwithJAVA&TheUserBasedMemoryManagementinC.

7.JAVAsupportsMethodOverloadingwhileCdoesnotsupportoverloadingatall.
8.UnlikeC,JAVAdoesnotsupportPreprocessors,&doesnotreallythem.

9.ThestandardInput&OutputFunctionsCusestheprintf&scanffunctionsasitsstandardinput&outputwhileJAVAusestheSyst
functions.
10.ExceptionHandlinginJAVAAndtheerrors&crashesinC.

3.In header files whether functions are declared or defined?


http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 1/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

Functionsaredeclaredwithinheaderfile.Thatisfunctionprototypesexistinaheaderfile,notfunctionbodies.Theyaredefinedinlibr

4.What are the different storage classes in C ?


TherearefourtypesofstorageclassesinC.Theyareextern,register,autoandstatic

5.What does static variable mean?


Staticisanaccessqualifier.Ifavariableisdeclaredasstaticinsideafunction,thescopeislimitedtothefunction,butitwillexistsfor
Valueswillbepersistedbetweensuccessive
callstoafunction

6.How do you print an address ?


Use%pinprintftoprinttheaddress.

7.What are macros? what are its advantages and disadvantages?


Macrosareprocessordirectivewhichwillbereplacedatcompiletime.
Thedisadvantagewithmacrosisthattheyjustreplacethecodetheyarenotfunctioncalls.similarlytheadvantageistheycanreduce
values.

8.Difference between pass by reference and pass by value?


Passbyvaluejustpassesthevaluefromcallertocallingfunctionsothecalledfunctioncannotmodifythevaluesincallerfunction.Bu
addresstothecallerfunctioninsteadofvalueifcalledfunctionrequirestomodifyanyvalueitcandirectlymodify.

9.What is an object?
Objectisasoftwarebundleofvariablesandrelatedmethods.Objectshavestateandbehavior

10.What is a class?
ClassisauserdefineddatatypeinC++.Itcanbecreatedtosolveaparticularkindofproblem.Aftercreationtheuserneednotknow
class.

11.What is the difference between class and structure?


Structure:Initially(inC)astructurewasusedtobundledifferenttypeofdatatypestogethertoperformaparticularfunctionality.ButC
containfunctionsalso.
Themajordifferenceisthatalldeclarationsinsideastructurearebydefaultpublic.
Class:ClassisasuccessorofStructure.Bydefaultallthemembersinsidetheclassareprivate.

12. What is ponter?

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 2/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

Pointer isavariableinaprogramissomethingwithaname,thevalueofwhichcanvary.Thewaythecompilerandlinkerhandlesth
aspecificblockofmemorywithinthecomputertoholdthevalueofthatvariable.

13.What is the difference between null and void pointer?


ANullpointerhasthevalue0.voidpointerisagenericpointerintroducedbyANSI.Genericpointercanholdtheaddressofanydata

14.what is function overloading


Function overloading isafeatureofC++thatallowsustocreatemultiplefunctionswiththesamename,solongastheyhavediffe
followingfunction:
intAdd(intnX,intnY)
{
returnnX+nY
}

15.What is function overloading and operator overloading?

Functionoverloading:C++enablesseveralfunctionsofthesamenametobedefined,aslongasthesefunctionshavedifferentsetso
theirtypesareconcerned).Thiscapabilityiscalledfunctionoverloading.Whenanoverloadedfunctioniscalled,theC++compilersel
examiningthenumber,typesandorderoftheargumentsinthecall.Functionoverloadingiscommonlyusedtocreateseveralfunctio
similartasksbutondifferentdatatypes.
OperatoroverloadingallowsexistingC++operatorstoberedefinedsothattheyworkonobjectsofuserdefinedclasses.Overloaded
equivalentfunctioncalls.Theyformapleasantfacadethatdoesn'taddanythingfundamentaltothelanguage(buttheycanimproveu
maintenancecosts).

16.what is friend function?


A friend function foraclassisusedinobjectorientedprogrammingtoallowaccesstopublic,private,orprotecteddataintheclass
Normally,afunctionthatisnotamemberofaclasscannotaccesssuchinformationneithercananexternalclass.Occasionally,suc
theprogrammer.Underthesecircumstances,thefunctionorexternalclasscanbedeclaredasafriendoftheclassusingthefriendk

17.What do you mean by inline function?


Theideabehindinlinefunctionsistoinsertthecodeofacalledfunctionatthepointwherethefunctioniscalled.Ifdonecarefully,this
performanceinexchangeforincreasedcompiletimeandpossibly(butnotalways)anincreaseinthesizeofthegeneratedbinaryexe

18.Tell me something about abstract classes?

Anabstractclassisaclasswhichdoesnotfullyrepresentanobject.Instead,itrepresentsabroadrangeofdifferentclassesofobjec
extendsonlytothefeaturesthatthoseclassesofobjectshaveincommon.Thus,anabstractclassprovidesonlyapartialdescription

19.What is the difference between realloc() and free()?

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 3/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

Thefreesubroutinefreesablockofmemorypreviouslyallocatedbythemallocsubroutine.UndefinedresultsoccurifthePointerpara
Pointerparameterisanullvalue,noactionwilloccur.Thereallocsubroutinechangesthesizeoftheblockofmemorypointedtobyth
numberofbytesspecifiedbytheSizeparameterandreturnsanewpointertotheblock.ThepointerspecifiedbythePointerparamet
themalloc,calloc,orreallocsubroutinesandnotbeendeallocatedwiththefreeorreallocsubroutines.Undefinedresultsoccurifthe
pointer.

20.What is the difference between an array and a list?

Arrayiscollectionofhomogeneouselements.Listiscollectionofheterogeneouselements.
ForArraymemoryallocatedisstaticandcontinuous.ForListmemoryallocatedisdynamicandRandom.
Array:Userneednothavetokeepintrackofnextmemoryallocation.
List:UserhastokeepinTrackofnextlocationwherememoryisallocated.
Arrayusesdirectaccessofstoredmembers,listusessequentialaccessformembers.

21.What are the differences between structures and arrays?


ArraysisagroupofsimilardatatypesbutStructurescanbegroupofdifferentdatatypes

22.What is data structure?


Adatastructureisawayoforganizingdatathatconsidersnotonlytheitemsstored,butalsotheirrelationshiptoeachother.Advance
betweendataitemsallowsdesigningofefficientalgorithmsforthemanipulationofdata.
23. Can you list out the areas in which data structures are applied extensively?
CompilerDesign,

OperatingSystem,
DatabaseManagementSystem,

Statisticalanalysispackage,
NumericalAnalysis,

Graphics,
ArtificialIntelligence,
Simulation

24.What are the advantages of inheritance?

Itpermitscodereusability.Reusabilitysavestimeinprogramdevelopment.Itencouragesthereuseofprovenanddebuggedhighqu
problemafterasystembecomesfunctional.

25. what are the two integrity rules used in DBMS?

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 4/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

Thetwotypesofintegrityrulesarereferentialintegrityrulesandentityintegrityrules.Referentialintegrityrulesdictatethatadatabas
keyvalues.Thismeansthat
Aprimarykeyvaluecannotbemodifiedifthevalueisusedasaforeignkeyinachildtable.Entityintegritydictatesthattheprimaryk

26. Tell something about deadlock and how can we prevent dead lock?
Inanoperatingsystem,adeadlockisasituationwhichoccurswhenaprocessentersawaitingstatebecausearesourcerequestedb
waitingprocess,whichinturniswaitingforanotherresource.Ifaprocessisunabletochangeitsstateindefinitelybecausetheresou
usedbyotherwaitingprocess,thenthesystemissaidtobeinadeadlock.
MutualExclusion:Atleastoneresourcemustbenonshareable.[1]Onlyoneprocesscanusetheresourceatanygiveninstantoftim
HoldandWaitorResourceHolding:Aprocessiscurrentlyholdingatleastoneresourceandrequestingadditionalresourceswhicha
NoPreemption:Theoperatingsystemmustnotdeallocateresourcesoncetheyhavebeenallocatedtheymustbereleasedbytheh
CircularWait:Aprocessmustbewaitingforaresourcewhichisbeingheldbyanotherprocess,whichinturniswaitingforthefirstpr
general,thereisasetofwaitingprocesses,P={P1,P2,...,PN},suchthatP1iswaitingforaresourceheldbyP2,P2iswaitingfora
PNiswaitingforaresourceheldbyP1.[1][7]

Thuspreventionofdeadlockispossiblebyensuringthatatleastoneofthefourconditionscannothold.
27. What is Insertion sort, selection sort, bubble sort( basic differences among the functionality of the three sorts and not th

28. What is Doubly link list?

Adoublylinkedlistisalinkeddatastructurethatconsistsofasetofsequentiallylinkedrecordscallednodes.Eachnodecontainstw
referencestothepreviousandtothenextnodeinthesequenceofnodes.Thebeginningandendingnodes'previousandnextlinks,
terminator,typicallyasentinelnodeornull,tofacilitatetraversalofthelist.Ifthereisonlyonesentinelnode,thenthelistiscircularlyl
beconceptualizedastwosinglylinkedlistsformedfromthesamedataitems,butinoppositesequentialorders.
29.What is data abstraction? what are the three levels of data abstraction with Example?

Abstractionistheprocessofrecognizingandfocusingonimportantcharacteristicsofasituationorobjectandleaving/filteringoutthe
situationorobject.
Letstakeapersonasexampleandseehowthatpersonisabstractedinvarioussituations

Adoctorsees(abstracts)thepersonaspatient.Thedoctorisinterestedinname,height,weight,age,bloodgroup,previousorexistin
Anemployersees(abstracts)apersonasEmployee.Theemployerisinterestedinname,age,health,degreeofstudy,workexperien

Abstractionisthebasisforsoftwaredevelopment.Itsthroughabstractionwedefinetheessentialaspectsofasystem.Theprocesso
givensystemiscalledasModeling(orobjectmodeling).
Threelevelsofdataabstractionare:
1.Physicallevel:howthedataisstoredphysicallyandwhereitisstoredindatabase.
2.Logicallevel:whatinformationordataisstoredinthedatabase.eg:Databaseadministrator
3.Viewlevel:endusersworkonviewlevel.ifanyamendmentismadeitcanbesavedbyothername.

30.What is command line argument?

Gettingtheargumentsfromcommandpromptincisknownascommandlinearguments.Incmainfunctionhasthreearguments.The

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 5/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

Argumentcounter
Argumentvector
Environmentvector

31.Advantages of a macro over a function?


MacrogetstoseetheCompilationenvironment,soitcanexpand#defines.Itisexpandedbythepreprocessor.

32.What are the different storage classes in C?


Auto,register,static,extern

33.Which header file should you include if you are to develop a function which can accept variable number of arguments?
stdarg.h

34.What is cache memory ?

CacheMemoryisusedbythecentralprocessingunitofacomputertoreducetheaveragetimetoaccessmemory.Thecacheisasm
whichstorescopiesofthedatafromthemostfrequentlyusedmainmemorylocations.Aslongasmostmemoryaccessesarecached
latencyofmemoryaccesseswillbeclosertothecachelatencythantothelatencyofmainmemory.

35.What is debugger?
Adebuggerordebuggingtoolisacomputerprogramthatisusedtotestanddebugotherprograms

36. Const char *p , char const *p What is the difference between the above two?
1)constchar*pPointertoaConstantchar('p'isn'tmodifiablebutthepointeris)
2)charconst*pAlsopointertoaconstantChar
Howeverifyouhadsomethinglike:
char*constpThisdeclares'p'tobeaconstantpointertoanchar.(Charpismodifiablebutthepointerisn't)

37. What is Memory Alignment?

Datastructurealignmentisthewaydataisarrangedandaccessedincomputermemory.Itconsistsoftwoseparatebutrelatedissue
structurepadding.

38.Explain the difference between 'operator new' and the 'new' operator?

Thedifferencebetweenthetwoisthatoperatornewjustallocatesrawmemory,nothingelse.Thenewoperatorstartsbyusingopera
thenitinvokestheconstructorfortherighttypeofobject,sotheresultisarealliveobjectcreatedinthatmemory.Ifthatobjectcontai
embeddedorasbaseclasses)thoseconstructorsasinvokedaswell.

39. Difference between delete and delete[]?

Thekeyworddeleteisusedtodestroythesinglevariablememorycreateddynamicallywhichispointedbysinglepointervariable.

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 6/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

Eg:int*r=new(int)
thememorypointedbyrcanbedeletedbydeleter.
delete[]isusedtodestroyarrayofmemorypointedbysinglepointervariable.
Eg:int*r=new(inta[10])
Thememorypointedbyrcanbedeletedbydelete[]r.

40. What is conversion constructor?

Aconversionconstructorisasingleparameterconstructorthatisdeclaredwithoutthefunctionspecifier'explicit'.Thecompilerusesc
objectsfromthetypeofthefirstparametertothetypeoftheconversionconstructor'sclass.Todefineimplicitconversions,C++usesc
constructorsthatacceptasingleparameterandinitializeanobjecttobeacopyofthatparameter.

41.What is a spanning Tree?


Aspanningtreeisatreeassociatedwithanetwork.Allthenodesofthegraphappearonthetreeonce.Aminimumspanningtreeisa
thetotaledgeweightbetweennodesisminimized.

42. Why should we use data ware housing and how can you extract data for analysis with example?
Ifyouwanttogetinformationonallthetechniquesofdesigning,maintaining,buildingandretrievingdata,Datawarehousingistheide
premeditatedandgeneratedforsupportingthedecisionmakingprocesswithinanorganization.
Herearesomeofthebenefitsofadatawarehouse:

oWithdatawarehousing,youcanprovideacommondatamodelfordifferentinterestareasregardlessofdata'ssource.Inthisway,i
analyzeinformation.

oManyinconsistenciesareidentifiedandresolvedbeforeloadingofinformationindatawarehousing.Thismakesthereportinganda

oThebestpartofdatawarehousingisthattheinformationisunderthecontrolofusers,sothatincasethesystemgetspurgedover
andsafelystoredforlongertimeperiod.

oBecauseofbeingdifferentfromoperationalsystems,adatawarehousehelpsinretrievingdatawithoutslowingdowntheoperationa

oDatawarehousingenhancesthevalueofoperationalbusinessapplicationsandcustomerrelationshipmanagementsystems.

feedback
oDatawarehousingalsoleadstoproperfunctioningofsupportsystemapplicationsliketrendreports,exceptionreportsandtheactua
Data mining is a powerful new technology to extract data for analysis.

43.Explain recursive function & what is the data structures used to perform recursion?

a)Arecursivefunctionisafunctionwhichcallsitself.
b)Thespeedofarecursiveprogramisslowerbecauseofstackoverheads.(ThisattributeisevidentifyourunaboveCprogram.)
c)Arecursivefunctionmusthaverecursiveconditions,terminatingconditions,andrecursiveexpressions.

Stackdatastructure.BecauseofitsLIFO(LastInFirstOut)propertyitremembersitscallersoknowswhomtoreturnwhenthefunct
makesuseofsystemstackforstoringthereturnaddressesofthefunctioncalls.Everyrecursivefunctionhasitsequivalentiterative(

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 7/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

whensuchequivalentiterativeproceduresarewritten,explicitstackistobeused.

44.Differentiate between Complier and Interpreter?


Aninterpreterreadsoneinstructionatatimeandcarriesouttheactionsimpliedbythatinstruction.Itdoesnotperformanytranslation
entireinstructions

45.What is scope of a variable?


Scopereferstothevisibilityofvariables.Itisveryusefultobeabletolimitavariable'sscopetoasinglefunction.Inotherwords,thev

46.What is an interrupt?
Interruptisanasynchronoussignalinformingaprogramthataneventhasoccurred.Whenaprogramreceivesaninterruptsignal,i

47.What is user defined exception in Java?


Thekeywordsusedinjavaapplicationaretry,catchandfinallyareusedinimplementinguseddefinedexceptions.ThisExceptioncla
Throwableclass.

48.What is java Applet?


AppletisjavaprogramthatcanbeembeddedintoHTMLpages.Javaappletsrunsonthejavaenableswebbrowserssuchasmozila
designedtorunremotelyontheclientbrowser,sotherearesomerestrictionsonit.Appletcan'taccesssystemresourcesontheloca
makethewebsitemoredynamicandentertaining.

49.What do you know about the garbage collector?

Garbagecollectionisthesystematicrecoveryofpooledcomputerstoragethatisbeingusedbyaprogramwhenthatprogramnolong
thestorageforusebyotherprograms
(orprocesseswithinaprogram).Italsoensuresthataprogramusingincreasingamountsofpooledstoragedoesnotreachitsquota
abletofunction).

Garbagecollectionisanautomaticmemorymanagementfeatureinmanymodernprogramminglanguages,suchasJavaandlangua
LanguagesthatusegarbagecollectionareofteninterpretedorrunwithinavirtualmachineliketheJVM.Ineachcase,theenvironme

feedback
responsibleforgarbagecollection.

50.Write a Binary Search program


intbinarySearch(intarr[],intsize,intitem)
{
intleft,right,middle
left=0
right=size1

while(left<=right)
{

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 8/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

middle=((left+right)/2)

if(item==arr[middle])
{
return(middle)
}

if(item>arr[middle])
{
left=middle+1
}
else
{
right=middle1
}
}

return(1)
}

51.What are enumerations?


Anenumerationisadatatype,usedtodeclarevariablethatstorelistofnames.Itisactlikeadatabase,whichwillstorelistofitemsin
shapes{triangle,rectangle,...

52.What is static identifier?

Thestaticidentifierisusedforinitializingonlyonce,andthevalueretainsduringthelifetimeoftheprogram/application.Aseparate
variables.Thisvaluecanbeusedbetweenfunctioncalls.Thedefaultvalueofanuninitializedstaticvariableiszero.Afunctioncanal
whichhasthesamescopeofthestaticvariable.

53.What is Cryptography?
Cryptographyisthescienceofenablingsecurecommunicationsbetweenasenderandoneormorerecipients.Thisisachievedbyth

feedback
(withacomputerprogramandasecretkey)andleavingtherecipienttounscramblethemessage(withthesamecomputerprograma
bethesameasthesender'skey).
Therearetwotypesofcryptography:Secret/SymmetricKeyCryptographyandPublicKeyCryptography

54.What is encryption?

Encryptionisthetransformationofinformationfromreadableformintosomeunreadableform.

55.What is decryption?
Decryptionisthereverseofencryptionit'sthetransformationofencrypteddatabackintosomeintelligibleform.

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 9/10
7/21/2016 TCSTechnicalInterviewQuestionsandAnswers

56.What exactly is a digital signature?


Justasahandwrittensignatureisaffixedtoaprintedletterforverificationthattheletteroriginatedfromitspurportedsender,digitalsi
foranelectronicmessage.Adigitalsignatureisanencryptedversionofamessagedigest,attachedtogetherwithamessage.

GetinTouchwithus
(https://www.facebook.com/freshersworld)
(http://twitter.com/freshersworld)
(http://www.linkedin.com/company/freshersw
(https://plus.google.com/+freshersworld)
(https://www.youtube.com/user/fre
com)

AboutUs(http://www.freshersworld.com/aboutus) Blog(http://blog.freshersworld.com) FAQs(http://www.fre

AdvertiseWithUs(http://www.freshersworld.com/advertise) RecruitmentSolutions(http://corp.freshersworld

ContactUs(http://www.freshersworld.com/contactus)

20062016Freshersworld.com

feedback

http://placement.freshersworld.com/tcstechnicalinterviewquestionsandanswers/33122057 10/10

You might also like