CONCEPTS In Java -GPS OOPS => * OOPs * Here Overview object oriented p rogramming means object means real world entity like Procedural Programming Program is divided called , parts functions . Doesn't provide a data into to wayto gives importance hide function freely. and data moves Overloading is not possible Inheritence is Code not possible reusability does not present Eg -Pascal : , C , FORTRAN er . I Car , ATM , . Bike ele OOPS Program is divided into objects Objects provides data hiding , . gives importance to data Overloading is possible Inheritence Code Gg :- possible is reusability Java , C# , is present Python , C ++ . c . Objects & Classes => 2 Object has things * Properties - Behavior - For Dog is * Car * - - - Class is a To create an So - Eg : a - breed , sleep , eat exc , Apply Type brake , , object , we , class the can , class is a use : . etc . - Brand , weight Drive , Increase blueprint I skeleton class To create , : colour Colour like be created From , Bark : provides class Function object because it has Behavior like can - an Properties , - is State object because an Behavior like - - : or Properties like : Age - ↓ Example or :- of an esc . . speed etc object . . required template or blueprint from which creat . multiple objects keyword class : - Class Student S int age ; string mama ; string address ; J Dataariables an object () update Address J I E 3 get Age return age : 3 Now let's create Student engStu It can be Car : we * - achieved Cellphone show . : Method typeStudent. - ; Data Abstraction implementation and shows . user only essential through interface and abstract classes the How ! BRAKE increases of pedal , and if we That is ABSTRACTED how call is Advantages St Data . :- onlyBut will reduce - for the Method Student (C new It hides the internal Example - = of * functionality * object B Pillar of OOPs => * an Data made Abstraction security & that : its press from it us ABSTRACTED - confidentiality , car . to us . speed DEMO : - & Car Interface 1) public apply Brake public inc public handbrake)); ; Speed 1); " 3 Class cargmp & public E Car implements apply Il Step - Brake 1 11 Step 2 11 Step- 3 - ! 3 3 So internally it's invoking Step-1, but Step-e---but all that is hidden from the ultimately when user calls apply Brake)) , user car stops. So this security internal only functionality improves as and user is not knows awa re about of the the . result => ↳ 2 Millar of OOMS - DATA ENCAPSOLATION Encapsulation bundles the data a single unit Also * Steps to achieve encapsulation - known as - on that data in DATA-HIDING Declare variable Provide public of class a private as setters getters the variables * working . * - code Advantages of encapsulation Loosely coupled control $ :- code -Better access security . DEMO : class Dog S private E string Dog ; string get Colour return (( this colour ; , 3 Set Colour this colour-colour ; E 3 /string colour) void to I view the modify values y let's Now create Dog lab lab lab . class which we 11 will return black ; haven't given the Instead dog . in turn have => 3 unde Lillar * Capability of a of Dog type ("black") ; Color get - object Dog(); new Set Colour So here of = an we the did it with the of access of OOPS class access variable . the variable colour help of the getter setter INTERITENCE - to inherit of properties from their parent class don't functions and variables so that have for write them in the child class again Can be achieved extends through interface keyword using inheritance * Types of Single inheritence It can inherit both * we . * or : - - - Multilevel - Hierarchical - diamond the - - innecitence Multiple inheritence to * inheritence problem We reusability can but diamand problem Advantages Of Code (Not achieve actually supported by through interface , we . Inheritence polymorphism using inheritence Java due can solve . . DEMO : Vehicle (Parent) - to Vehicle Class E Car boolean boolean 1 child) engine ; get Engine (( E return this engine ; 3 3 Class Car extends Vehicle & string type ; K string getCarType E return this 3 Now let's create Car an type ; object Car of . CarK ; swift 1) Swift get Engine ; = new - : Vehicle Vehicle vehicle . = new getCarType)) ; Vehicle 1) 11 - ; Should not work So since Swift , hence * it can is an call Single object g get Engine car which whereas extends vice versa Class it ↓ Class B * Multilevel Class it ↓ Class B ↓ Class * 2 Hierarchical Class it I ↳ ~ Class B Class ( vehicle isn't possible Multiple * 21 ass Class B A * - &S & Class - I his is problem => * not s 42 Millar Poly is a but there upported in workaround of OOPS If same method behaves , * Example - * - - - Java due to diamond for using interfaces it . POLMORPUISM "Many" & morphism means * - ( means differently "Form" in different situation : it person Water can can be be husband , fathersolid , liquid Types of polymorphism : , or . employee esc gas . - Compile Time /Static Polymorphism /Method Overloading Run Time / Dynamic Polymorphism /Mechod Overriding DEMO : class Sum E (inta int doSum , in + b) 5 return a + b ; 3 int doSum (inta , intb , inte) E return a 3 So this + b + c; of creating practice methods with same different perometers is ka overloading Bo the method will be called based on name . the parameters Pass A E Class B extends it int ( get Engine E E int return 1j S 3 getaugine(( retur 3 2 but ; . let's Now Bobj . overeiding everything i.e. arguments , , method Is - - through Doa : Inheritence - a return is Kla type , relationship a Example Has * , this is same . name Achieved - - - at runtime oversiding. method * decided method to call is which So in object of class i 11 This'll return 2 obj getEngine) ; So an B 1) ; new = create inheritence animal is - a from an is - . relation a between its parent child classes relationship Whenever , object is used in an Other class , it's calld HAS-A relationship . - - Relation Ship could be one-to-one , Example · · School Bike has one-to-many many-to-many , students engine has School has classes · - Association : relationship · · Aggregation ending of Both between I different objects individually survive objects will not end another one object object Composition - can , means . - Ending of one . object will end another object