[!INDEX]
- 1.04-Copy_Ct
- Definition
- Use
- copy ct example-1, name,age A copy constructor has a single parameter that is an object of the same class.
- Deep copy address example ( Create new memory location )
- Shallow Copy
- Deep Copy
- Shallow copy address example ( sharing the reference )
- Key Points:
- 1.05-Inheritance
- Def. - allow subclass to inherit , ct() pt()
- single inheritance - father money son job
- multilevel inheritance-grandfather- father- son
- hierarchy Mother - daughter - son
- multiple inheritance , same son inherit two father money mt()
- child subclass implicitly call parent class NO ARGUMENT ct()
- child subclass explicitly call parent class ARGUMENT ct().+super
- Rules for parent ct
- 1.06-iS-a_has-a
- def - is a - subclass inherit...
- def - has a - one class contains or is composed ...
- def - composition ( strong form, life cycle, owned)
- def - aggregation ( week form, not - life cycle, owned)
- is a code dog subclass of animal ( dog is a animal) code
- code : composition = car, engine
- code : aggregation = car, engine
- 1.07-mt-ol-1
- Poly - allows one mt() or object to behave in different ways depending on the context in which it is used
- ol-Definition + multiple mt() + same name + diff sign.
- Exceptions
- Not depends on return type (below is wrong), int and string
- type of Mt -OL ( number, data, sequence )
- AP ( char ) = (string) & (int)
- Data type priority List (BSC ILFD)
- Implicit Widening Conversion -( windening - small to larger ) (implicitly conversion - one to another data )
- (char)= (object) & (String)
- Autoboxing ( primitive - corresponding - wrapper class )
- (null) = (Stringbuffer) & (String)
- above solution + ((String)null) + ((StringBuffer)null)
- (int, int) = (float, int) & (int, float)
- above solution = (10, 20.0f) + (10.0f, 20)
- ct() ol - car() + car(" ") + car( " ", 12) + car( " ", 12, " ")
- 1.08-mt-ol-2
- (float, float) = (int, float) & (float, int)
- (int, int) = (int) & (int... a)
- (int,int,int) = (int) & (int... a)
- ( ) + (null) = (int) & (int... a)
- (int) = (float) & (double) & (long).
- (int) = (float) & (double)
- (int) = (float) & (string)
- (byte) & (char) & (short) = (int) & (string)
- main method overloading
- 1.09-Access_Mod.
- Access Modifiers and Their Priority
- Summary of Access Modifiers
- Example
- Conclusion
- 1.10-Protected_AM
- File Structure
- Protected_AM
- Default_AM
- Private_AM
- Public_AM
- 1.11-mt-ol-1
- Def. - subclass provides a specific implementation
- Points + same + override + access + exception + constructor
- Example one ( animal, dog, cat + makeSound mt
- Covariant object - string + allow a mt() in a subclass to return...
- Reasons for Covariant Return Types
- Practical Example code with ( animal and dog return type )
- Access Modifier ( From protected to public )
- Why subclass can make the method more accessible
- Unchecked Exception in child only
- Rules for Exceptions in Method Overriding
- checked e/x in
child only- child and parent throw same run time e/x
- Parent Throws Parent Exception, Child Throws Child Exception
- Pt. Throws Unchecked E/x, Child Attempts to Throw Checked E/x
- 1.12-mt-ol-2
- Calling Parent Class Method Using
super( mom - son)- more practical example of super, credit card
- Final , Not override, pie value
- Static , Not override, ElectricBoard example
- private , Not override, family picture
- Pt M/T Synchronized, Acceptable
- Child M/T Synchronized, Acceptable
- Child mt() Is Strictfp, Version Dependent, java 17
- parent mt() is strictfp, version dependent
- Abs. Cls. + Abs. + Concrete Mt., no body defined,
instantiate directly- why Abs. cls. cannot be instantiated directly
- Abs. Cls. + Abs. Mt. inherit + body defined + OK
- Itf. mt() implemented + body not defined
- Itf. mt() + Abs. mt() + must defined body - OK
- 1.03-Constructor
- Def.- special + primary purpose.
- five Points ( default, same, return, overload, invoke)
- Default argument ct , test class obj. access instance var i.
- Above code with NO ARGUMENT CT(), compiler wont make.
- parametrized ct(), above code with no arguent + argument ct calling
- instantiate vs initialization
- 1.02-New,Dot
- employee class obj e1 initialisation + this + ct() + new + display mt()
- data type of number(4 type), decimal (2 type ), char, boolean, and object with string.
- create dog array and put 3 dog in it.
- Dot operator
- employee class 2 obj. initilize name + no ct+ no mt
- employee class 2 obj. initilize name + with mt() + emp detail mt()
[!INDEX]
- 2.1-abstract_class
- Definition + Hiding the complex implementation details..
- Abstract Classes + abs mt + concrete mt ( animal , dog)
- Benefits of Abstraction
- method without body : must declare abstract
- inherit abs. cls. without implement its mt(). body : + Vehicle+ start + car
- code : above correct code + vehicle + car
- code : make abs. cls. obj. in main m/t. + vehicle + car + scooter
- code : above correct code abs. class variable instantiate subclass
- 2.2-Interface
- Interfaces
- General Code, animal dog
- method without abstract keyword, default public abstract
- method with body in interface : wrong way
- method with body having default keyword : Code
- Why use default keyword
- Ambiguity Resolution( multiple method with same name)
- Static method + override ( wrong )
- Example Use Case of static mt. in interface : as a utility functions
- Variable in interface-1
- Variable in interface-2
- Class inherit interface mt with weaker access modifier
- 2.3-Encapsulation
- Definition
- Code Example employee name age with validation
- Explanation
- Example Without Encapsulation:
- Without Encapsulation Explain
- Benefits of Encapsulation:
- Summary
- 2.4-this
- Definition
- To refer to instance variables of the current object
- To call one constructor from another (Constructor Chaining) + approach
- To pass the current object as an argument + approach
- To return the current object from a method + approach, setname to the employee.
- Why is this useful?
- To invoke the current class's method.+approach
- To access the current class's instance from an inner class
- Summary of
thisUsage:- 2.5-super
- Definition
- Calling the Superclass Constructor (
super()), animal - dog - main .- Accessing Superclass Method (
super.methodName()) animal - dog - main .- Accessing Superclass Field (
super.fieldName) animal - dog - main .- 2.6-static_1
- Definition
- Use
- Can't declare static Var. In M/t.
- sT Var. Can't Directly Access In Another cls.( without cls name)
- sT Var. Can Directly Access In Another cls. withs its cls. Name
- Non sT Var. Can Not Access In Another sT cls. Using cls. Name
- employee obj. init. ( id,name,comp) using c/t , w/o using sT
- employee obj. init. ( id,name,comp) using c/t , with static keyword.
- counter program using instance Var..
- counter program using sT Var..
- 2.7-static_2
- non sT m/t call using obj. in same class.
- non sT m/t call in static method w/o using obj in same class
- sT m/t call using cls. name and directly in same class
- different class method can't call directly (both static).
- different class method call directly using class name (both static).
- sT m/t can only access sT data ( int 1 = 10; ).
- sT m/t can't call sT m/t directly in same class.
- sT m/t Cannot Refer To 'This' Or 'Super' Keyword In Anyway.
- Only sT Block Executes Automatically When The Cls. Is Loaded In The Memory.
- Only sT Block + Main M/T sT Block Executes First Then Main m/t.
- Multiple sT Block In cls., Executes Top To Bottom, sT Members Executes First.
[!INDEX]
- 3.1-Exception_hirerachy
- Basic exception code ( 1 to 9 , between 100/0 )
- hierarchy
- Differences Between Errors and Exceptions
- Error code ( using recursive mt )
- Exception code ( filenotfound using BufferReader)
- 3.2-checked_uncheck
- Definition
- Compile-Time Exception (Checked Exception)
- Runtime Exception (Unchecked Exception)
- points to remember
- 3.3-try_catch_1
- Exception flow ( 7 points ).
- arithmetic ex. Handling Using try-catch ( div/0 )
- code flow + try-catch + rest code + no error ( 1 to 7 code )
- code flow + arithmetic ex. + try-catch + rest code + error ( above code )
- method of ex. object printing( 4 way )
- only try block
- cH block only
- fn/y block only
- 1 tR multiple cH, same eX type
- 1 tR multiple cH, parent-chid eX.
- 1 tR multiple cH, chid-parent eX.
- 3.3-try_catch_2
- try - finally block
- same child exception in multiple blocks
- tR - fn/y and try - cH block sequence ,works fine
- nested tR-cH in try block and cH. : works fine
- tR with nested tR-cH in ch block
- tR-cH , nested tR-cH in finally block. : works fine
- tR block, code statement then cH block
- single tR with multiple cH, same parent chid-chid eX
- tR-finally-catch
- 3.4-finally_block
- Points and Definition.
- finally block will not execute if ( exit, fatal, e/x final, death)
- syntax try-catch-finally syntax
- try-catch-finally and no arithmetic ex. ( div/2 mt() )
- try-catch-finally and + arithmetic ex. ( above code )
- try-finally + arithmetic ex. + error ( above code )
- try-finally with arithmetic exception occur + rest code
- use of finally ( resource )
- 3.5-final_finally_finalize
- final Keyword (1 point)
- finalize() Method (7 points )
- finally Block (5 points )
- compare table
- Example Combining All Three code
- 3.6-throw_keywrod (div method)
- Definition ( 3 points ) + divide /0 mt().
- Example code arithmetic ex in calling mt()
- ex. handle in calling class + try-catch ( above code )
- ex. handle in caller class + try-catch ( above code )
- exception flow theory ( 5 points )
- throw keyword ( 8 points )
- Syntax of throw.
- Throwing r/t e/x, + no try-catch + error ( student age )
- above code + try-catch + error ( above code )
- above code + try-catch + no error ( above code )
- Approach
- 3.7-custom_exception (UnderAgeExceptions)
- Approach ( 4 points ) + UnderAgeExceptions
- custom checked e/x + error + throw + without handle( not compile ) + above code
- custom checked e/x with error + try-catch + above code
- r/T e/X with throws( compiler not detect the issue) + not handle + above code
- r/T e/X + try-catch + throw + above code
- statement after throw ( error) +throw + try-catch + above code
- 3.8-throws
- Definition ( 3points )
- unhandled exception in caller method(file read write)
- Exception handling in caller method with try-catch (file read write) + no file
- Exception handling in caller method with try-catch + file.
- difference between throws and throw.(6 points, MRSBN, DCMSC)
[!INDEX]
- 4.1-Strings
- non primitive dT. ( reference, reference describe, nonpdt-store value)
- General Code for string str as a reference
- Differences Primitive - Non Primitive : (memory, method, null)
- String implemented as a array/(Sequence) of characters ( char[] , charat[] mt)
- charAt[] mt code for, str = "Hello"
- Character Array to string output :
- charSequence interface ( read only + method + implements)
- CharSequence code mt =lenght +charAt +subSequence +toString
- Why Use CharSequence( flexibility (don't restrict), buffer builder)
- code StringBuilder implements CharSequence
- summery about above code
- string as a class ( package, sequence of array, immutable )
- Syntax of the
StringClass(SCC):- Key Points of the
StringClass:- 4.2-SCP_SPL
- Points( code + stroe + reuse +version)
- Code ( obj.1 + lit.2 + obj.3 + obj.1(only 1) + lit.1(0, reuse) )
- String s2 = new String(); everytime new, even in SCP
- Code - 2 diff string using same literal
- Disadvantages:( memory , slower, rare use)
- 4.3-Immutablity
- Immutability concept
- String immutability ( Cannot Change) + concat mt("python")
- image explain
- why string object are immutable-practical example + agra + goa
- String Immutable? security(url), SCP( one chane-all change)
- Difference between final( mt, field class) and immutability(string obj.)
- Table of difference
- 4.4-
equals()_vs_(==)
- comparison
==vsequals- Points to Remember
- syntax for object, boolean mt ( equals for reference )
- syntax for class, boolean mt ( equals for object )
- 4.5-String_ct
- string constructor, string, buff, build, char[] z, byte[] d
- real codes for ct();
- why char is used for password storage ( char string ct()=string, char=object )
- syntax for class, boolean mt ( equals for object )
- 4.6-String_mt
- trim, lenght, isEmpty, equal { s1.mt() } + validation
- compair to , compairToIgnoreCase (lexiographly)
- string with +
- concat , join, Subsequence, substring, indexOf, lastIndexOf,
- syntax for class, boolean mt ( equals for object )
- 4.7-Buffer_vs_builder
- String Buffer
- Code Example+ use append hello + world
- Syntax (ASC)
- StringBuilder
- Code Example+ use append hello + world
- constructor+method
- 4.8-buil_buf_mt_ct
- Buffer Constructor + SB() + SB("raj") + mt() capacity
- lenght, charAt, delete, deleteCharAt
- equals, indexOf, lastIndexOf, insert, replace, reverse
- subSequence, substring, setCharAt, setLength, ensureCapacity, trimToSize
- 4.9-Garbage_coll
- Garbage collection( automatic memory management)
- Key Concepts of Garbage Collection(AMM + HP- NO ref. + reachability + algorithm)
- Types of Garbage Collection Algorithms( serial ,parallel, CMS, G1)
- How Garbage Collection Works
- Benefits of Garbage Collection
- Example of Garbage Collection in Action
- Conclusion
- garbage collection in SCP
- Understanding SCP and Heap Memory
- Why Garbage Collection Doesn't Apply to SCP
- When Strings from SCP Might Be Collected
- Conclusion