You are on page 1of 12
lasstute [Name : Tsmail.M-Shaieh Sub 2 OOPM CyAVA) aS sem +. IL _ Assignment No- 4 s@ Te apply fundamental proguamraing vonstuds . Q-4 | What ts object Onented Progamming ? Elaborate iffenent -ooP's concepts wit suitable escomples. > object ~ oriented Progamming DO method for designing O_progiam usin lasces g objects . called al a object Oviented amming i alto core of fava . OOP organizer oO. promiam qxnound objects well-defined tnterce Tis com alto ¥ chanacterized ar data routyolling fox the accessing the tode . Th Hil type “of approach programmes definethe lata pe of a data | stuctwye ¢ the operations thad plied t | clevelop ment & maintenance by wrung Some OOP concepts - _ _ objects oe always Hf Catted cu Lo class Objects: core creeetecl From Ye eb othe) leenguage obj< a behaviour. 0 classmate, Example : public class muybook § int a= 10; public State void main (String argsc7) { MYbook muob/ = new muyubook(); ystem, out .prnttn Gayoby, “a): | F b) Classes: Classes aye like object Constructors Fox creccting objects. The collection of objectr is itecttect-satd to be a Class. Classes oe said fo be Jegicat quantitfer. Classes don't consume any Space jn the memory. Class is also called a template of Gn _obfect. Example - We have a class which has data members Such os speed, weight, price and functions Such as yeorrchange C) SlowDown Cy brake C) ett, ©) Data sbshacton: Rreling Intemnal detutte & Showing : : + Ranch onatity is7tnown ai Abstraction. Tt te a process of binding the implementoHon detuilr 6 Showing only the functronetity 4 Excample * ITaKing & pictune on a smevuphonp « 1S Listening te music using headphones. d Encap surtattio _ ——— ~——_—___|l —Encapsutation refes te sePr a oe da | & methods into the single unit» == O's The dy | with the code that manipulate it FE _KEEPS the Ldeta € the code safe from external fntenface, | Example: : -______| A _ctass tec an example ef encapsutotion iy Compucten science in that it consits of data and meth thet have been jnte_a single unit ie) Inheutance: Tt ts the process by whith one Clalt acquuitye the Propectiet of objects of another class we Can oclefine Wnhenitence ar‘ the process by whick objects of one class get the propertic! of objects of cunothey class. 4 Example: A child inhetitr the traits of p anew iF) Polymorphism : | Bt _{s the proters greek term in whith Poly! [mean mony & ‘movph’ means "form" -Polu nox phism | means rw the ability to take more theun one Tm: |fcample: ikea fother a husband jon employee .»S | __th€_ Same pensor posses tiftenent behoviowt in different situctione, 6 What jc constuctor ? Explain “cons buctoy oventoacing | with surtable examples - a) Constructor is a speciat type of method that is | used to initiatixe the object + Constructor ts | tavoe d ot the time of object creccon Tt wns buck | the values Le. provides the data fer that i why it ie) known as Construction: Ore Genstuietien Constuctoxt can be classiffed into bvo Byers D Default Conshuctors lidterametenized Cory tructors Gonstuctoy Overloaching : i In java i is a technique ‘of lhaving more than one conctructor with clifferent ponometey Lists They arte arewnged in a wooy theeet leoch constructor performs a_diffenent task. They Lone liffenentiatec by the tompilen by the numbey lof parameters in the (ist § Hut types -_ class Stuclent_ | 4 a oe Example: int icy Sting nome 5 int age) gtuclert (int it, string ny [Writ ® note on the followin. ob jArrayC Ij yee clepaxtment [ue]; types. _ Classname _ € All array consists ot (ontiguous memory \ocoHory . THe lowey celcbiess jorrespondess to He Art elem -& Me highest adcltets-to the last elemect- ii Lil) Vetoes: l Vectors ane same ar dynamic arrays | the ability to resize itself acctomat cally when element 18 inserted wr deleted, with ther Sto I being handled. Automatically by the container -Ue elements ote pleiced ff continquous storage so Hat a can be accessed and trawersed usin nil): Steings : ee = | Strings ove fanclamertteat_pevut of oll _Cempusting languageg. String ba clata structure He con hold ce Seiet of Cheoteicters . Thes | ways bo create using object __ 9) BY Shing Aitene| _b) By new Keyword i I —||— i classmate | — | pele cece eaeno ancien aan 5 Eee name=n; (oS: % ‘vote chisplay ©) 5 System, out. pantly Ud" "snomet" "rage ); j public SteH'c_yoid mam Cstning arms I) 5 Stuclentt §1-= new StudenteCol, "Ismau "5 Stuclentr ¢2 = mew Cteclenty [o2, "Shoaib" 21) 5 Si. chivplay O; ca. AuplayO; 5 5 o/p: o| Tsmou 0 o2 Shoarb 24 ao -—§:4_| Explain the super § Fino bey = | a)Supen: I ta keyword of fava whith sete he inom e dict Vpenierct St a class and it te use Inside the subclass method definétion ae cellin Qa method defined in the supet Class ASMP Ole Class. Syntax: Supey ©) } Ub) foe}: Pt bia keyword i in, java thet ig used to restruct the use 5 can be Wed in many espe Frnet can be used with” classes". mmethoels” ," variable A_method declaredl as “Final cannot be veal qhis means even when a child closs con call the_ Final metnods of potent class without any issue lout the overutiding will_pot be porcible. Tmplementaltion of tt is allowed to throw t | t 1 OS Differentiate between tnrow & throws: > i i Key throw throws | ; D Ipefinition [throw is 4 Keyword which Throws is a keyword used is used to Hnow oh exceptionlin the method siqnadute ! explicitty in the program used te declare an Inside a -Renction or Insid@ | excoption which night get : a block of code. thrown by the funaten. aD Decloation [fn oxdey to Ue tro Keywo} On othe hound Haws * rd _we Should now Prot |eeyword is used vith throw Keyword is used Imetrod siqnature. within Mmethoels ii) interme [Datemedl Howe is implemented we declare muttiple exceptione with throws vonly single exuption at tine, Keyword that could get iie--we cannot tow multiple, Lexccepan with threw Keyword thrown “by the funclan where Rrrows Leyword is uted ») Syntax Syntax with throw Keyword is Syntax wice Knows Keyword followed) by the instonce is followed by exception vortiable- class name. Fn fava, a thread otways exists the following _states. These States one 1D pewbern State: hot, i ‘s the Signtficente. © of: routltenlng. Spin | the hreacl cycle» —EE 4 4, ee tt to $8 provi orton “execution of two on mone | parts of ustlze the CPO time, in any one of | CA “progparn to _rnascien | Arte “creasion | of the thread object, “the thread is born which is colled as newborn thread LTAis thread is not eched wed for_running we Ccun oithe Stevuts_this _stete to make if runnable uting srawl) method .on last the thread ywsing Stee) method. only these two separations can be peiformed on fats state of the thread: when the thread js ready for escecutior and tt is woting for_availoibibty of of the processer it_ts said te be in -yennable state. The thread hal jeined fhe queue of threads that axe wolltng yr execution TF att the thread have quel — Lpriovity, then they axe given time slot? for exeut! ic_yound robin Fashion -te.on Fixet Come Arte Senvey_basis .The thread that fetinguithet: “co teins to anethe ‘thread of equal priovity _yelel_ method can be used. ss classmate. Hts Running Stete : when the processor hat given time to the thread for tts execution than the thread fs said to be In winning State The thread -nens until it_ reas relinguishes ‘Covitrol: to Tt pwn ov it is preempted -by a hiqghen priority “threaol+ A Sreenning thread may relinquishes “d's Crcbtol fs ony “ane of the Following si terotioy ° a)The thread has been suspended wing suspend ©) method - THis can be revived toy using resume C) method. this is eRe) when we want to Suspend a thread for some time better tran killing b> we Can put o thread to sleep using Sleep Ctime) method, Hme it He time volte given in milliseconds means, the threacl © the out of the quete dwing 3 the time pextod. oA thrpad can watt unttl some evertt occeve using 3 wort © method - |e Raping Ee ____|iv) Blocked Queue: t When a threete) is. He en | enteding into the runnable stare & -cubsequ ip wunning stete it ip satel +e be ‘locked Aus ~ happens when the threcal ix Suspended. Sleeping” by wetting jm order to satisfy cretatn a ° i ; ak’ poh =. requirements -A blockecl thread is considenea * not _vunnable’ but not dead and therefore Fully | qualitied sk0 YUU, again Lv) Dead state: ; | a sunning Hhreotal encls its Life when jt has Completed it's excectttion of vin) metned- Tt is aq netweul ceath , Howevert, we can Kill it by sending the Stop message te Te ok any Stetw rhus, e€ Causing oo prematwie eleccth to ik: classmate. Explain AWT Draw AWT Hierarchy Sava _AWT (Abstract window Teolkit) io an APT to_clevelope graphicout usen Trtenface on windows based on applications java: “Java _AWT tomponenit one platform -depenclent ie. components axe” ditplayed acterding to the view of OS: AWT is heovyweight 9 ve. THs it components ane using the resources of “underlying openating System COS) The Java _awt package provicles “classes for AWwT APT Such as Textftela, label, TextAren, RaclioButtons | Checkbox ;cpoice, Lut, ete. | object | | Com} onent | (7 Butten | Re f j lobe | ! LJ checktoox | | Choice I—] West | —] tentainer | [wincow fane | l F Framel [Dietoae Tapp tet]

You might also like