You are on page 1of 24

EngineeringInterviewQuestions.

com
Engineeringinterviewquestions,multiplechoicequestions,objectivetype
questions,seminortopics,labvivaquestionsandanswers,onlinequiztestpdffree
downloadforfreshers.
HOME interviewQuestions MCQs *LABVIVA CLASSNOTES SEMINARTOPICS
ONLINETEST GATE IITJEE CAT

HomeC++ProgrammingQuestionsandAnswers100
TOPC++ProgrammingMultipleChoiceQuestions
andAnswers

100TOPC++Programming
MultipleChoiceQuestionsand
Answers

PostedonNovember17,2015 byengineer
Comments

C++ProgrammingMultipleChoice
QuestionsandAnswers:
1.IftheclassnameisX,whatisthetypeofitsthispointer
(inanonstatic,nonconstmemberfunction)?
a.constX*const
b.X*const
c.X*
d.X&
2.Whichclassesallowprimitivetypestobeaccessedas
objects?
a.Storage
b.Virtual
c.Friend
d.Wrapper
3.Whenisstd::bad_allocexceptionthrown?
a.Whennewoperatorcannotallocatememory
b.Whenallocfunctionfails
c.Whentyperequestedfornewoperationisconsideredbad,
thisexceptionisthrown
d.Whendeleteoperatorcannotdeletetheallocated
(corrupted)object

4.Whichoneofthefollowingisnotafundamentaldatatype
inC++
a.float
b.string

Loading

Engineering
Questions
Facebook

c.int
d.wchar_t
5.Whichofthefollowingisavaliddestructoroftheclass
nameCountry
a.int~Country()
b.voidCountry()
c.int~Country(Countryobj)
d.void~Country()
6.WhichofthefollowingcorrectlydescribesC++language?
a.Staticallytypedlanguage
b.Dynamicallytypedlanguage
c.BothStaticallyanddynamicallytypedlanguage
d.Typelesslanguage
7.Whichofthefollowingkeywordsupportsdynamicmethod
resolution?
a.abstract
b.Virtual
c.Dynamic

Finduson
GooglePlus

d.Typeid
8.Whichofthefollowingisthemostpreferredwayof
throwingandhandlingexceptions?
a.Throwbyvalueandcatchbyreference.
b.Throwbyreferenceandcatchbyreference.
c.Throwbyvalueandcatchbyvalue
d.Throwthepointervalueandprovidecatchforthepointer
type.
9.Whichofthefollowingisnottrueaboutpreprocessor
directives
a.Theybeginwithahashsymbol
b.Theyareprocessedbyapreprocessor
c.Theyformanintegralpartofthecode
d.Theyhavetoendwithasemicolon
10.Whatswrong?while((i<10)&&(i>24))
a.thelogicaloperator&&cannotbeusedinatestcondition
b.thewhileloopisanexitconditionloop
c.thetestconditionisalwaysfalse
d.thetestconditionisalwaystrue
11.Acontinuestatementcausesexecutiontoskipto
a.thereturn0statement
b.thefirststatementaftertheloop

c.thestatementfollowingthecontinuestatement
d.thenextiterationoftheloop
12.Whatswrong?(x=4&&y=5)?(a=5)(b=6)
a.thequestionmarkshouldbeanequalsign
b.thefirstsemicolonshouldbeacolon
c.therearetoomanyvariablesinthestatement
d.theconditionaloperatorisonlyusedwithapstrings
13.Whatswrong?for(intk=2,k<=12,k++)
a.theincrementshouldalwaysbe++k
b.thevariablemustalwaysbetheletteriwhenusingafor
loop
c.thereshouldbeasemicolonattheendofthestatement
d.thecommasshouldbesemicolons
14.Whichofthefollowingisnotrecommendedinaheader
file?
a.Typedefinitions(typedefs)
b.Classdefinitions
c.Functiondefinitions
d.Templatedefinitions
15.WhichoftheSTLcontainersstoretheelements
contiguously(inadjacentmemorylocations)?
a.std::vector

b.std::list
c.std::map
d.std::set
16.Whichofthefollowingisnotastandardexceptionbuiltin
C++.
a.std::bad_creat
b.std::bad_alloc
c.std::bad_cast
d.std::bad_typeid
17.WhatdoesSTLstandfor?
a.SimpleTemplateLibrary
b.StandardTemplateLibrary
c.StaticTypeLibrary
d.SingleTypebasedLibrary
18.Whatisthedifferencebetweenoverloadedfunctionsand
overriddenfunctions?
a.Overloadingisadynamicorruntimebindingand
Overridingisstaticorcompiletimebinding
b.Redefiningafunctioninafriendclassiscalledfunction
overridingwhileRedefiningafunctioninaderivedclassis
calledanoverloadedfunction.
c.Overloadingisastaticorcompiletimebindingand
Overridingisdynamicorruntimebinding

d.Redefiningafunctioninafriendclassiscalledfunction
overloadingwhileRedefiningafunctioninaderivedclassis
calledasoverriddenfunction.
19.Whichoneofthefollowingisnotavalidreservedkeyword
inC++
a.Explicit
b.Public
c.Implicit
d.Private
20.Eachpassthroughaloopiscalleda/an
a.enumeration
b.iteration
c.culmination
d.passthrough
CorrectAnswerstoC++MCQQuestions
1d2b3d4a5b6d7a8b9a10d
11c12d13b14d15c16a17b18b19c20
c
21.Whichofthefollowingistrueaboutconstmember
functions?
a.constmemberscanbeinvokedonbothconstaswellas
nonconstobjects
b.constmemberscanbeinvokedonlyonconstobjectsand
notonnonconstobjects
c.nonconstmemberscanbeinvokedonconstobjectsaswell
asnonconstobjects
d.noneoftheabove

22.Whichofthefollowingrelationshipisknownas
inheritancerelationship?
a.hasarelationship
b.isarelationship
c.associationrelationship
d.noneoftheabove
23.IfclassAisfriendofclassBandifclassBisfriendofclass
C,whichofthefollowingistrue?
a.ClassCisfriendofclassA
b.ClassAisfriendofclassC
c.ClassAandClassCdonothaveanyfriendrelationship
d.Noneoftheabove
24.Adirectaccessfileis:
a.Afileinwhichrecoredsarearrangedinawaytheyare
insertedinafile
b.Afileinwhichrecordsarearrangedinaparticularorder
c.Fileswhicharestoredonadirectaccessstoragemedium
d.Noneoftheabove
25.Whichofthefollowingisnotacomponentoffilesystem
a.Accessmethod
b.Auxiliarystoragemanagement
c.Freeintegritymechanism
d.Noneoftheabove
26.Seektimeis
a.timetakentoretrieveadta
b.Timetakenbyread/writeheadmechanismtopositionitself
overappropriatecylinder
c.Timetakenbyappropriatesectortocomeunderread/write
d.Noneoftheabove
27.Primeareaincontextoffilesystemisdefinedas
a.Itismemoryareacreatedbyoperatingsystem
b.Itisanareaintowhichdatarecordsarewritten
c.Itisthemainareaofawebpage
d.Noneoftheabove

28.Inmulitlistorganization
a.Recordsthathaveequivalentvalueforagivensecondary
indexitemarelinkedtogethertoformalist.
b.Recordsareloadedinorderedsequencedefinedby
collatingsequencebycontentofthekey
c.Recordsaredirectlyaccessedbyrecordkeyfield
d.Noneoftheabove
29.Whichofthefollowingis/areadvantagesofcellular
partitionedstructure:
a.Simultaneousreadoperationscanbeoverlapped
b.Searchtimeisreduced
c.Botha&b
d.Noneoftheabove
30.*ptr++isequivalenetto:
a.ptr++
b.*ptr
c.++*ptr
d.Noneoftheabove
31.Theconditionalcompilation
a.Itistakencareofbythecompiler
b.Itissettingthecompileroptionconditionally
c.Itiscompilingaprogrambasedonacondition
d.noneofabove
32.OriginallyCwasdevelopedas:
a.Systemprogramminglanguage
b.Generalpurposelanguage
c.Dataprocessinglanguage
d.Noneofabove
33.Aninvertedfile
a.Locatesinformationaboutdatainsmallfilesthatare
maintainedapartfromactualdatarecord
b.Afilewhichstoresoppositerecords
c.Afilewhichstoresinformationaboutrecordsofasystem
d.Noneofabove

34.Whichofthefollowingisnotafileoperation:
a.Repositioning
b.Truncating
c.Appending
d.Noneofabove
35.Latencytimeis:
a.Timetakenbyread/writeheadmechanismtopositionitself
overappropriatecylinder
b.Timetakentotransferadtafrommemory
c.Timetakenbyappropriatesectortocomeunderread/write
head
d.Noneofabove
36.ThetwotypesoffilestructureexistinginVSAMfileare
a.Keysequencedstructure,entrysequencedstructure
b.Keysequencestructure,exitsequencedstructure
c.Entrysequencestructure,exitsequencedstructure
d.Noneofabove
37.Howmanycopiesofaclassstaticmemberareshared
betweenobjectsoftheclass?
a.Acopyofthestaticmemberissharedbyallobjectsofa
class
b.Acopyiscreatedonlywhenatleastoneobjectiscreated
fromthatclass
c.Acopyofthestaticmemberiscreatedforeachinstntiation
oftheclass
d.Nomemoryisallocatedforstaticmembersofaclass
38.Whichloopingprocesschecksthetestconditionattheend
oftheloop?
a.for
b.while
c.dowhile
d.noloopingprocesschecksthetestconditionattheend
39.Thedefaultaccesslevelassignedtomembersofaclassis
___________
a.Private
b.Public

c.Protected
d.Needstobeassigned
40.Whichofthefollowingcorrectlydescribesthemeaning
ofnamespacefeatureinC++?
a.Namespacesrefertothememoryspaceallocatedfornames
usedinaprogram
b.Namespacesrefertospacebetweenthenamesinaprogram
c.Namespacesrefertopackingstructureofclassesina
program.
d.Namespacesprovidefacilitiesfororganizingthenamesin
aprogramtoavoidnameclashes.
CorrectAnswerstoC++MCQQuestions
21b22a23b24c25c26d27b28b29a
30c
31d32c33b34a35d36c37c38a39c
40a
41.Whichofthefollowingcorrectlydescribesthemeaningof
namespacefeatureinC++?
a.Namespacesrefertothememoryspaceallocatedfornames
usedinaprogram
b.Namespacesrefertospacebetweentehnamesinaprogram
c.Namespacesrefertospacebetweenthenamesinaprogram
d.namespacesprovidefacilitiesfororganizingthenamesina
programtoavoidnameclashes
42.WhichofthefollowinglanguageisnotsupportedbyC++?
a.ExceptionHandling
b.Reflection
c.OperatorOverloading
d.Namespaces
43.classderived:publicbase1,publicbase2{}isanexample
of
a.Polymorphicinheritance
b.Multilevelinheritance
c.Hierarchicalinheritance
d.Multipleinheritance

44.WhichofthefollowinglanguagesisasubsetofC++
language?
a.Clanguage
b.JavaLanguage
c.C#language
d.language
45.Howdowedeclareaninterfaceclass?
a.Bymakingallthemethodspurevirtualinaclass
b.Bymakingallthemethodsabstractusingthekeyword
abstractinaclass
c.Bydeclaringtheclassasinterfacewiththekeyword
interface
d.ItisnotpossibletocreateinterfaceclassinC++
46.Howdowedeclareanabstractclass?
a.Byprovidingatleastonepurevirtualmethod(function
signaturefollowedby==0)inaclass
b.Bydeclaringatleastonemethodabstractusingthe
keywordabstractinaclass
c.Bydeclaringtheclassabstractwiththekeywordabstract
d.ItisnotpossibletocreateabstractclassesinC++
47.Whichofthefollowingisnotanadvantageofsecondary
memory
a.Itiscosteffective
b.Ithaslargestoragecapacity
c.Ithashighestspeed
d.Itiseasilyportable
48.Whathappenswhenapointerisdeletedtwice?
a.Itcanaborttheprogram
b.Itcancauseafailure
c.Itcancauseanerror
d.Itcancauseatrap
49.Whichofthefollowinglanguagefeatureisnotanaccess
specifierinC++?
a.public
b.private

c.Cprotected
d.internal
50.ExpressionC=i++causes
a.ValueofiassignedtoCandtheniincrementedby1
b.itobeincrementedby1andthenvalueofiassignedtoC
c.ValueofiassignedtoC
d.itobeincrementedby1

C++ProgrammingMultipleChoiceQuestionsand
Answers::
51.Thestatementi++isequivalentto
a.i=i+i
b.i=i+1
c.i=i1
d.i
52.InClanguage,ahexadecimalnumberisrepresentedby
writing
a.x
b.xo
c.ox
d.h
53.Whichofthefollowinglibraryfunctionbelowbydefault
abortstheprogram?
a.Terminate()
b.end()
c.Abort()
d.exit()
54.Ifamemberneedstohaveuniquevalueforalltheobjects
ofthatsameclass,declarethememberas
a.Globalvariableoutsideclass
b.Localvariableinsideconstructor
c.Staticvariableinsideclass
d.Dynamicvariableinsideclass
55.Valueofix+j,ifi,jareintegertypeandixlongtypewould
be
a.integer

b.float
c.longinteger
d.doublepercision
56.Whichofthefollowingbelowcanperformconversions
betweenpointerstorelatedclasses?
a.A.cast_static
b.B.dynamic_cast
c.c.static_cast
d.D.cast_dynamic
57.Howdowedefineaconstructor?
a.a.x~(){}
b.B.X(){}~
c.C.X()~{}
d.D.~X(){}
58.Vtables
a.createsastatictableperclass
b.createsastatictableperobject
c.createsadynamictableperclass
d.createsadynamictableperobject
59.WhenclassBisinheritedfromclassA,whatistheorderin
whichtheconstructersofthoseclassesarecalled
a.ClassAfirstClassBnext
b.ClassBfirstClassAnext
c.ClassBsonlyasitisthechildclass
d.ClassAsonlyasitistheparentclass
60.Whichofthefollowingisthemostgeneralexception
handlerthatcatchesexceptionofanytype?
a.catch(std::exception)
b.catch(std::any_exception)
c.catch()
d.catch()
CorrectAnswerstoC++MCQQuestions
41d42d43b44d45a46a47a48c49d
50d

51a52b53d54a55b56c57C58D59a
60a
61.Whichofthefollowingisthemostgeneralexception
handlerthatcatchesexceptionofanytype?
a.catch(std::exception)
b.catch(std::any_exception)
c.catch()
d.catch()
62.Inagroupofnestedloops,whichloopisexecutedthe
mostnumberoftimes?
a.theoutermostloop
b.theinnermostloop
c.allloopsareexecutedthesamenumberoftimes
d.cannotbedeterminedwithoutknowingthesizeoftheloops
63.WhatistheDifferencebetweenstructandclassintermsof
AccessModifier?
a.Bydefaultallthestructmembersareprivatewhileby
defaultclassmembersarepublic.
b.Bydefaultallthestructmembersareprotectedwhileby
defaultclassmembersareprivate.
c.Bydefaultallthestructmembersarepublicwhilebydefault
classmembersareprivate.
d.Bydefaultallthestructmembersarepublicwhileby
defaultclassmembersareprotected.
64.Inlinefunctionsareinvokedatthetimeof
a.Runtime
b.Compiletime
c.Dependsonhowitisinvoked
d.Bothbandcabove
65.Whatisshallowcopy?
a.Ashallowcopycreatesacopyofthedynamicallyallocated
objectstoo.
b.Ashallowcopyjustcopiesthevaluesofthedataastheyare.
c.Ashallowcopycreatesacopyofthestaticallyallocated
objectstoo
d.Bothbandcabove

66.Whatisdeepcopy?
a.Adeepcopycreatesacopyofthedynamicallyallocated
objectstoo.
b.Adeepcopyjustcopiesthevaluesofthedataastheyare.
c.Adeepcopycreatesacopyofthestaticallyallocatedobjects
too
d.Bothbandcabove
67.Whichofthefollowingbelowis/areavaliditeratortype?
a.InputIterator
b.BackwardIterator
c.ForwardIterator
d.Bothaandcabove
68.Whatdefinesageneralsetofoperationsthatwillbe
appliedtovarioustypesofdata?
a.Templateclass
b.Functiontemplate
c.Classtemplate
d.Bothaandcabove
69.Underwhichofthefollowingcircumstances,
synchronizationtakesplace?
a.Whenthefileisclosed
b.Whenthebufferisempty
c.Explicitly,withmanipulators
d.bothaandc
70.Whichofthefollowingfunctionsbelowcanbeused
Allocatespaceforarrayinmemory?
a.calloc()
b.malloc()
c.Realloc()
d.bothaandb
71.Statementscanf(%d,80)
a.Assignanintegertovariablei
b.Giveanerrormessage
c.Printthevalueofi
d.Assignanfloattovariablei

72.STLisbasedonwhichofthefollowingprogramming
paradigms?
a.StructuredProgramming
b.ObjectOrientedProgramming(OOP)
c.FunctionalProgramming
d.AspectOrientedProgramming(AOP)
73.STLisbasedonwhichofthefollowing
programmingparadigms?
a.StructuredProgramming
b.ObjectOrientedProgramming(OOP)
c.FunctionalProgramming
d.AspectOrientedProgramming(AOP)
74.Ifthereismorethanonestatementintheblockofafor
loop,whichofthefollowingmustbeplacedatthebeginning
andtheendingoftheloopblock?
a.parentheses()
b.braces{}
c.brackets[].
d.arrows<>
75.Whichofthefollowingmembersdogetinheritedbut
becomeprivatemembersinchildclass
a.Public
b.Private
c.Protected
d.Alltheabove
76.Whichloopingprocessisbestusedwhenthenumberof
iterationsisknown?
a.for
b.while
c.dowhile
d.allloopingprocessesrequirethattheiterationsbeknown
77.InaClanguage3represents
a.Adigit
b.Aninteger
c.Acharacter
d.Aword

78.Whichofthefollowingisthemostcommonwayof
implementingC++?
a.C++programsaredirectlycompiledintonativecodebya
compiler
b.C++programsarefirstcompiledtointermediatecodebya
compilerandthenexecutedbyavirtualmachine
c.C++programsareinterpretedbyaninterpreter
d.AC++editordirectlycompilesandexecutestheprogram
79.Whichheaderfileshouldweincludeforusing
std::auto_ptr?
a.
b.
c.
d.
80.Whichofthefollowingoperatorscanbeimplementedasa
nonmemberoperator?
#NAME?
b.()(functioncalloperator)
c.[.(arrayaccessoperator)
d.+(additionoperator)
CorrectAnswerstoC++MCQQuestions
61c62c63b64c65b66b67a68d69b
70d
71a72a73c74c75b76c77a78c79a80
c
81.Whatistheimplicitpointerthatispassedasthefirst
argumentfornonstaticmemberfunctions?
a.selfpointer
b.std::auto_ptrpointer
c.Myselfpointer
d.thispointer
82.Whichofthefollowingoperatorscanbeoverloaded?
a..(dotormemberaccessoperator)
b.&(addressofoperator)
c.sizeofoperator
d.?:(conditionaloperator)

83.Whichofthefollowingoperatorcannotbeoverloaded?
#NAME?
b.==(equalityoperator)
c.>(rowoperator)
d.::(coperesolutionoperator)
84.Whichofthefollowingoperatorsbelowallowtodefinethe
memberfunctionsofaclassoutsidetheclass?
a.::
b.?
c.
d.%
85.Whichofthefollowingisnotavalidconditionalinclusions
inpreprocessordirectives
a.#ifdef
b.#ifundef
c.#endif
d.#elif
86.Whichofthefollowingisnotastandardexceptionbuiltin
C++.
a.std::bad_creat
b.std::bad_alloc
c.std::bad_cast
d.std::bad_typeid
87.Ifamemberneedstohaveuniquevalueforalltheobjects
ofthatsameclass,declarethememberas
a.Globalvariableoutsideclass
b.Localvariableinsideconstructor
c.Staticvariableinsideclass
d.Dynamicvariableinsideclass
88.Underwhichofthefollowingcircumstances,
synchronizationtakesplace?
a.Whenthefileisclosed
b.Whenthebufferisempty
c.Explicitly,withmanipulators
d.bothaandc

89.Whichofthefollowingfunctionsbelowcanbeused
Allocatespaceforarrayinmemory?
a.calloc()
b.malloc()
c.Realloc()
d.bothaandb
90.Whichofthefollowingisnotavalidconditionalinclusions
inpreprocessordirectives
a.#ifdef
b.#ifundef
c.#endif
d.#elif
91.Valueofaina=(b=5,b+5)is
a.Junkvalue
b.Syntaxerror
c.5
d.10
92.Minimumnumberoftemporaryvariableneededtoswap
thecontentsof2variablesis:
a.1
b.2
c.3
d.0
94.Thereisnothinglikeavirtualconstructorofaclass.
a.False
b.True
95.C++providesfacilitytospecifythatthecompilershould
matchfunctioncallswiththecorrectdefinitionattherun
time.Thisprocessiscalledas
a.Staticbinding
b.DynamicBinding
96.Theoutputofthisprogramis
int
main(){cout<<HelloWorld!return0}

a.HelloWorld
b.Syntaxerror
c.0
d.HelloWorld!
97.Thereturnvalueofthefollowingcodeis
Class1&test(Class1obj)
{
Class1*ptr=newClass1()

returnptr
}
a.objectofClass1
b.referencetoptr
c.referenceofClass1
d.objectpointedbyptr
98.Theoutputof
{
inta=5
intb=10
cout<<(a>b?a:b)
}
a.5
b.10
c.Syntaxerror
d.Noneofabove
99.Theoutputofthisprogramis
inta=10
voidmain()
{
inta=20
cout<<a<<::a
}
a.Syntaxerror
b.1020

c.2010
d.2020
100.Observefollowingprogramandanswer
classExample{
public:inta,b,c
Example(){a=b=c=1}//Constructor1
Example(inta){a=ab=c=1}//Constructor2
Example(inta,intb){a=ab=bc=1}//Constructor3
Example(inta,intb,intc){a=ab=bc=c}//Constructor4
}
Intheaboveexampleofconstructoroverloading,the
followingstatementwillcallwhichconstructor
Exampleobj=newExample(1,2,3)
a.Constructor2
b.Constructor4
c.Constrcutor1
d.Typemismatcherror
CorrectAnswerstoC++MCQQuestions
81d82d83b84d85a86b87a88b89d
90a
91b92d93d94a95b96b97b98b99c
100b

PostedinC++ProgrammingQuestionsandAnswers

30TOPCOMPILERDESIGN
VIVAQuestionsandAnswers

100TOPCOMPUTER
NETWORKSMultipleChoice
QuestionsandAnswers

4THOUGHTSON100TOPC++PROGRAMMING
MULTIPLECHOICEQUESTIONSANDANSWERS
habtamu
SEPTEMBER7,2016AT1:31PM

veryexcellent!!!!
REPLY

yunusolaide
AUGUST15,2016AT10:54AM

thiswillhelpme
REPLY

aditya
JULY8,2016AT4:54PM

pl.sendmepdfofcomputersciencesubject
REPLY

aditya
JULY8,2016AT4:53PM

sirpleasesendmepdfofmcqoncomputer
science.Itsnicecollection
REPLY

LEAVEAREPLY
Youremailaddresswillnotbepublished.Requiredfieldsaremarked*

Comment

Name*

Email*

Website

PostComment

Engineeringinterviewquestions,multiplechoicequestions,objectivetypequestions,seminor
topics,labvivaquestionsandanswers,onlinequiztestpdffreedownloadforfreshers.
Terms&Conditions|PrivacyPolicy|Contactus|Aboutus

You might also like