0 ratings0% found this document useful (0 votes) 103 views10 pages?oops?interview Series
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
‘Le
y
bdd ddd’ f/f ee
Cecece
\
Poo obLvLvVLL
\y \
\
S2\3 >
\
S
4. [vahar Ss oor 2]
= oF. is SEHK as _Opjecr Ortenred Programming,
SyYTHIM th ONL programs are Considered Qs q colleution
OF Objeurs. Each obsecr Ie nothing bur an Instant of
Class
Lanite baste sie concerts. of Oop ?
Forjotlng are tne concepts OOP and are as Follows:
1. Abstraction 2. Encapsulation.
3: Innevitane YU. Porymorpnism-
3.| Whar tsa class 2
> A class is Simply o representation oF a type OF Objet
jt ts tne blue/Plan/ tempiare thar desertbe tre deralls
oF an objets ;
4.| Jainar ts an objer?
> Onseur 1s termed aS an Instane of a class, and tt has ths
Own stare, behaviouy and foentty.
5. | whar is Encapsularton 2
> Enwpswarion i¢ an attribure of an object, and it contains
gil dota udnith is hidden: Thar niaden data can be
yesreicred fo the member OF thar class+ Levels are Public,
Prorected, Private, Internal and Prorered Internal.
G+ | Wnor Is Poiymorenicm 2
> Foiymorpnism is notning but assfgning behavior oy value
in@ subclass t© Somerhing ynor Was aiveady declared
in ene main Class. CIMPIY, PolymorPNism fous more
nan one form:
NoTeES Gaecery CTECEYPOSS LL LLL LLLEddddddd de e/e/e/c/e/e/e/e'e’'e”
S
> Innevitane ts q concept woheve one Class shaves the Structure
And behavior defined I another class. Tf fnhevitanw applied
On one class Ty called ingle Inheritance ,and if it depends
on MUMple classes, then itis called Multiple Inhevitane.
%. Llanar axe Manipr
2 Manipulators are tu funutfons whlch can be used In
Conjuurton with the tnserton and extraction operators on an
objets Examples ave endl and ser «
9.| Define a constyutror?
? Construcroy 15 q method used to initlalize tu stare of an
objec, and it get Invoked at ime time of Objeur creation -
Rules For Consprucroy are!
. Ni howd be sqm
= NsStyruror OQ) Xi
Jo. | Define Destructor?
> Destructoy ts q method Wn Ts automatically called din
me Objeer fe made of scope oF destroyed. Destructure name
fs also same as class name bur with pu tide symbo)
before pe name.
u.[ Wwharts Initne function ?
> Iniine funution ts a Fechnique used by tre Compilers
and Instructs ro insert compiere body OF tre
Cunutton whereevey tar Funution Ps used In pe
Pregvam Souvnr (ode:42° [yonak ts vivtuat Faunaton |
>? \Mrtuot Funuton Ys a member Functlon oF class and its
Fanctonaltty can be overridden fn Tes ctevived class+ This
Funtton ean be Implemented by using a Keyword called
virtual, and it can be otven during Funcrion declaratton .
Virtual funerton can be achfeued tn Ctt and tr can be
Qthieved In C Language by using funution pointers or
Pointers to Function.
Friend Funaton ts a Friend of q class phar tr quowed to
access fo Public, Private, Proreured, gara In thor same
Class. If tu Function Ys defined ourstde Hu Class cannot
access suth Infoymarion- Friend an be declared anywhere
fn tu class Aeclavarton, and t+ cannot be affected by
Qecess contyo) KeyWords Ike Pylvare . public of prorecred-
1-| Alhat fc Funetton Overloading?
> Funutlon overloading ts defined as a normn Function,
bur ft has the abiifty to Perform differant tasks» It
anows Cieatton of sever methods With the same
name Unich atffey From eath other by type of input
and Olrpur of the funtton.
15+ | lAthax is Operator Overloaging 2
3 Operator Overloading ts 9 Function Where athRvenr
operators aye applied and depends on pr aiquments -
Operator, — x can be used fo PAss through rhe Punctton,
and Tt has thelr OWN precedenu to execure «
+
AruciumArR (LINKEDIN),
BSQOOEOELLELLLLLIDd ddd dddddl de"vuUle
ee
ec
lIWIWVWs
VALTALALALAL A 2) a a © WW
v
uv
oO
o
v
>
S
2
3
=)
2
2
2
2
2
2
D
xy
ve
a
a
n
n
SI Av iy i
16. [a9 at fs an abstract cla
> Fin gbstrate class Ts 9 class whith connor be Instantated+
Creatton of an objet 1s not possible wlth abstraur class,
bur tt can be Inherfeds An absetraer class can contoin
Only Abstvacr method. Java arlows only abstyaw
Muhod tn gbstvaur class udnhe For Otner language
tr alloWs non-gbstracr method gs Wells
19: [Iathar te a ternary operator?
2 Teynary Operaroy ts sald to be an Operatoy Which fakes
three atqumente. Avgumenrs and yesults are OF
clefertnt gara types, and It fs depends on tr Function,
Térnary operator fs also called gs Conditonoal opevaror -
Arye fume (UNK
SST
18] talnar Ps tre use of Finalize metnod 7
> Flaaitze merhod naps to Perform cleanup operations
ON the yesourvtes wWrSch aye not currently used= Fincuize
murhod ts prorered ,and it Ts gecessible only through
tris class oy by a devived class.
3 A pasamerer Is a Uarlable used during tre declavation
of pu Funuton oF subyoutlne qnd arguments are
passed to th funtrton , and tt Snotd marth colth pre
Parameres defined®
Tere are two types oF Arguments.
© Call by value — Value Passed wt get modtFied ony
insiad +m Funurton,and tt yerurns the same value
voharever Iris Passed tr Into tre Funerion .
* Cail by Reference — Value Passed WIL ger moatAted fn
hormigide and ourside tm funettons and It yerurns eng
came or differenr Value.WOOO e dd lddd dddddddeere’
\
ea)
3) Super keuyword ps used to Inuole overvidden merhod
with overrides one of Its Superciass methods. Tru's
Keyword allows fo Qeess overridden methods and also
tO ACCeSS Hfaaen members of pu superclass Lk aso
forards 9 cati from o constructor fo a constyuctor
Mn tre Superclass.
ai. Lathot Ts metnod Overviding 2
2 Muthod overriding ts a fearure thar allows subclass +0
Proulse Impiementatton of a munod Hor ts aiyeady
defined in tre maln class. Ths pol) overrides pa
Implementarion In ime superclass by providing tre same
MeUMNod Name, same pardamMURr and same ystuYn type.
22. |aynar fs an Interface 2
> An Ynterfaw Ys a colleurion of abstratr method - fF te
Class Impiementc an Inneritanu, and hen thereby
Ynherits al) tat abstraur memods of an Jnrefau.
23+|Winot te an exception nanaiing 2
> Exupton is an evenr nar Occurs during pe execu ton
of a program Exceptions can he of any type —
Runtime exception, Evror excepHons + Those excepHons
are Mandled properly through exeepifon handling
Mechanicm Wie try, caren and throw Keywords
24. /lanar ate tokens 7
2 Token Is rewgnized by 4 lomplter and Ir cannot be
brolen don Fnto Component elements. Keywords, fdent? Frey
constants, string Virerors And OPeTAOrs Art examprerel "|
foKanse Even punctuation chavatrers are also tonsidered
gs pojans — Rrakets, commas, graces and Parentheses,Sener wr rw rrr rrr eee eae
SOON
Ss
25.[Dleferenue bJwd overloading ana Overristna 7 |
OveRLoapin g 2 OVERRIDING
+ Overloading Ys storie binding. J» Oversfatng Ys dynamic binding,
+ Overloading Vs nortng bur tre |e Overriding Ts the same
SAME mepiod alin aiteerent Method name with same
Aeguments, and tt may or may} arguments and return
not veturn tha same votue in | types associates ulta sreclass
tre same class Ttsete. and Its cnlid class
‘[DieFevena Bw ciacs and Qn obser?
oeBsect CLASS
+ An object ic an tnstanu ofa [+ Class don't nave any
CASS. Jets hold any In formation.
informarion.
@ Obsek Soes not have © Class Can howe sub- classes
Stub - ObF Urs
29+|Winar Ys Qn abstraurton
2 foctraction ts a good fearuye of OOP, and tt shows only
He necessary daralis to tw Clfent ofan ober. Meany,
Tr shows Only necessary details for an ObjeUr, not tha
Ynney deralls of an objeu.
Example — wnen you want to Ststtth On relewsion ,}¢ not
Necessary +0 show ail the funuttons of Tw.
nareney fs vequlyed to suotteh On TY Util be
Snowed by using abstyaw cligss.
2%.llahar are access modt Fier?
> Access ModiFler determing thr scope OF tL Method or
varlapies thar can be aecessed from Orney various
obletr Or classes. There are 5 types of access modifiers,
and the are Qs Follows :
© Pytvore . ered ¢ Public e Fylend
© protected Firlend.
EES
Atoc kumar Coe keory)
Novel Gaiceryedddddd ddl erry
29. [winar Ts seated mogtéh vs 2]
> Sealed modifiers are tre access modthiers wWnere It
Cannot be Inherited by te methods. Cealed modiflers
CAN alsO be appited to ProperHers, events and merhods
TWs modifier cannot be appiled fo static members.
30.[How can We cal tre base erhod ustrnour creating an ins tand
2 Ves, It }s posstble to call the base method uirhour Creating
an Ynstana.And that method showd be, starle marnod -
Dotng Inheritana from thar class. — use Base Keyword
from delved class:
Bie [Winar Ts the dleeerence b/W new and oversise? |
3TH new modifier Instrucrcs tr compiler to Use pu new
ImMpiementorion Ynstead oF tre base class funuton -
amneveas, Override modifier haps to override th
base class function.
> TRert aye three varlous types of Construtors, ana they
are Qs Food t~. Default Constructor—litth no paramerers.
© Favamurrle Constyuttey — lalith Paramerers -
Create a new Instane of @ class Qnd also passing
arguments cimulraneously.
* COPY constyu4or —hWINich cyeares aq new objecras q
copy of an existing object.
33. [lAInaris cantly and hare binding ?
3 Early binding yeFers to assignment of Values to
Variables during design dlme whereas fare binging
yefors fo assfgnment Of Values to variables during
CIAKEDIN).WOSWSBOH ELLE LLL dLed dh ddd dds ells
\\
Bu. [anor Ys —tnis Polnrer 2 i
=> THIS pointer yefers to the current objet of a class:
THIS Kaytoord ts used Usa polnter WNch atererentares
HeTORen the cuvyene objecr Lolth the global object
Basteally tt yerers fo tei current Objent:
S5.[lnlnar Te tht aTeferenea bjw structure and a class?
2 _Staucture cunss
© Structure default access tyre Jo Class access type ts
Ts Pubite Privare .
© Struccure TS used for grouping} * class can be used to Qrouping
dara - dora and methods
© Srrucures ave exclusively © Classes ard Used fo encapscu-
USed for dota and It dees not] Ares and tnhevit dara wweh
yemtye A pure virtusl function ts a Funutton LoNich ean be
overridden In tre derived class bur Cannot be defined.
A ulyrun Funurton can be declared a's Fure by using
tri opevaror = 0.
33-[whar are alt the Opevator¢ that cannot be overloadea?]
= Following are tra goerarers tnar cannot be overloaded
4. Scope” Resoiution (::)
2. Member Selettton (.)
3 Memver selection tnroudn Q potnter to Functfon
Ce]WHISHOSSS§S HOO LLELEIEdbdEd dd ddd dd ddd d¥
3a) vanart is dynamic or yun time Poiymorprt sm 9]
) Dynamic ox Run time Polymorphism ts also Known as
method overriding tn vow can fan overvidden
Funton ts yesolved auring yun tle, not ar tre
Complle Hime: Tk means nauing two of move matnods
vottn txt came name, came Signature but wirh
Algeavent Impiemenratton .
4o.| Do We requlse Parameter for constvuerer |
3 No, We do nor yequlse paramerey For constyutrors -
a a cory Constructors?
3 Tris a Q ce constructor for Creating Q ned objet
Qsa copy of an existing, Object > There voll be alway s
only On LOPY Constructor that can be either defined
by tne user Ov TM System -
U2.| nar does tar Keyword virtual represented fn tre
mernod derinittion 2
3 It means, we can overvide the method.
=
us lainecnest ctaric method can Use Non static Member? |
EOS Cn
uy.[vanat are base class, Sub class and super class? |
3 Race class 1s te mOSt aeneratized Class ,and Mt is
sald fo bea yoot class. Sub class 15 class fmat
Inherits From ON oy MOTe hase Class + Super class
Ts ts parenk class From wWnith another class
tanerits:
mak CUNKEDIAL).Cbbbdd dddlelele/c/cecee
»LbbG
bob
La
KAY \ \
SSYOSBoSBbb
us-[punox Is Startc and dynamic binding? |
> Binding ts Noting bur prr Assodan'on of g name
volth pe class.
© Static tndin a t-
Sa binding in Which name can be
Assodartd with te class quying compilarion time, and
Yr is alse caned qs_ear inding .
+ Dynamite Bin dings Is aq binding in woNch name can be
assodared with me class during execution time, and it
$$ also cated as_tare Binding.
ue-[How many Instana can be created fox an abstvaur class?)
3 =Szyo Instanus wlll be cytared For an obstraer Class.
ur-[ranien Keyword can be used for Overloading 7]
> Operator Keyword Vs used My Overloading.
pipes mae
Spedfier in a class defialHon? |
ey \s used In Q Class SeFiniton.
lb aq
> Privare access spedhi
a se ey
ua. kanich OOPS Conuept is Used For yeuse Mechanism?
3 Innerttone is tne OOPS Coneept that can be used as
yeuse mechanism.
Inich OOPS ConcePt exposes Only necessQry Information
40 callin® Funuion ?
2 Data riding / Abstvacrion
LINKEDIN.)