00:00
/* d_001 - oops-2 points, oops-6 pillars */ 1. Oops object oriented programming langueage System. 2. it is a programming paradim/ or style 3. we will study oops only, 4. many types a. oops paradigm b. procedureal paradigm c. functional paradigm d. logical paradigm e. structured paradigm 5. oops 6 pillars a. class b. objects and methods c. inheritance d. polymorphism e. abstractions f. incapsulations
/* D_002 C=3, M/T=2, Obj=6 Points */ D_002 C=3, M/T=2, Obj=6 Points 1. class objects and methods 2. animal = class 3. objects = dog, cat, elephant 4. method ( task ) = eat run, // class= 1. collection of objects 2. not the real world entity 3. does not occupy the memory syntax = access_modifier class ClassName{ m/t, c/t, fields, blocks, nested class } // methods= 1. a set of codes which perform a perticular task 2,. java program must have main method advantage of methods 1. code reusebility 2. code optimization syntax access_modifier return_type method_name ( list of paramaters) { } // objects 1. it is a instance of class 2. is real world entity 3. occupy memory 4. object consist of - a. identity = ( like dog name) b. state/attribute = ( color, bread, age) c. behaviour = eat, run // how to create an object = 5 ways a. new keyword b. newInstance() methods c. clone() methods d. deserialization e. factory method
/* D03-[ Obj. Declare, instantiation , initialised using new ] */ Declaration = Animal buddy; Instantiation = buddy = new // allocate memery initialization = buddy = new Aniamal(); in single line Animal buddy = new Animal(); how to call an object , using dot operator buddy.method(like run) Declaration Animal Buddy; 1. Here, You're Declaring A Variable Named Buddy Of Type Animal. 2. This Means You're Telling The Compiler That You'll Be Using A Variable Named Buddy To Refer To Objects Of Type Animal. Instantiation (Allocation Of Memory): Buddy = New Animal(); 1. This Line Instantiates An Object Of The Animal Class. 2. The New Keyword Is Used To Allocate Memory For An Object Of Animal Class On The Heap. 3. This Newly Created Object Is Then Assigned To The Variable Buddy. Initialization Buddy = New Animal(); 1. The Process Of Initialization Occurs Simultaneously With Instantiation In This Case: 2. This Line Not Only Instantiates An Object But Also Initializes It With The Default Constructor Of The Animal Class. 3. In This Case, The Default Constructor Is Called, Which Might Set Initial Values Or Perform Any Other Necessary Initialization Steps Defined In The Animal Class. * 1. Default c/t ( no arguments) * 2. no arguments c/t ( user defined) * 3. paramterized c/t * * Default c/t ( no arguments) * 1. compiler generate itself * 2. JVM not Create - wrong
Home STOP NEXT