java opp
The meaning of Encapsulation, is to make sure that "sensitive" data is hidden from users.
it is like the pojo classes in andorid studio


To achieve this, you must :::
    1. declare class variables/attributes as private
    2. provide public get and set methods to access and update the value of a private variable


example :::
    public class Another {

        private int a;
        private int b;
        private int c;
    
        public Another(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    
        public Another(){
            // default
        }
    
        public int getA() {
            return a;
        }
    
        public int getB() {
            return b;
        }
    
        public int getC() {
            return c;
        }
    
        public void setA(int a) {
            this.a = a;
        }
    
        public void setB(int b) {
            this.b = b;
        }
    
        public void setC(int c) {
            this.c = c;
        }
    }
java opp
CONSTRUCTOR :
when the class is run the constructor also run 
java opp
Another way to achieve abstraction in Java, is with interfaces.

An interface is a completely "abstract class" that is used to group related methods with empty bodies:



note :::
    1. no concreate 
    2. only abstract

why use :::
    1. achieve abstraction
    2. multiple inheritance
    3. lose coupleing


lose coupleing:::
    it is when we change in one interface it will not change in other class

    
syantx :::
    interface interface_name{
        method      (public abstract) , (public static) , (private)
        fields      (public staic final)
        concreate   (only default)
    } 
    
java opp
abstraction is used for security 



def :::
    1. it is the deatail hiding and implementation of the services 
    2. data abstraction deals with exposing the interface to the user and hiding the details of implementation


real world example :::
    1. in car we will only show break and donot show internal parts
    2. in car we will only be showed straing but dont its internal parts 


to achieve abstraction :::
    1. abstract class ( 0 - 100% )
    2. interface      ( 100% )


what is in abstract class :::
    1. variable (no body)
    2. methods  (no body)
    3. methods modifier "abstract"
    4. class modifier   "abstract"   (it have no objects)
 

    note ::
        1. also can be make some concreate method (that have body)
        2. the class which inherte abstract class it will make body of abstract method
        3. "it will use the concept of method overridding"



example :::

    abstract class don{
        int butt ;
        abstract void start(int a);
    }
java opp
poly means        ( many )
morphism  mean    ( Form )
polymorphism      ( many forms )

example of polymorphism :::
    1. water has many forms  ( solid , liquid , gas )
    2. shapes has many forms ( circle , rectangle , square )
    3. sound has many forms  ( loin , male , female  )


types :::
    1. compile time polymorphism  ( static polymorphism )   ( handle by compiler )
    2. run time polymorphism      ( dyanmic polymorphism )  ( handle by jvm )


achieve by :::
    1. compile time polymorphism   ( method overloading )
    2. run time polymorphism       ( method overridding )


cases :::

    method overloading :::
        "1. if we pass character it will call int due to ( automatic promotion )
        2. if we pass character it will call object if it is in the arguments 
        3. if number of arguments (same datatype like in promotion) is large than no automatic promotion
        4. main method can be overload
        5. changing the return type cannot overload"

    method overridding :::
        ok ::
            "1. return type (covarent return type) change say ho sakta ha
                (we can provide parent in parent return type and child ma return type parent ki child honi chiya)
            2. access modifier 
                (child overridding access modifier is greater than parent overridding method)
            3. overridding and exception handling 
                (if parent class overridding method not throw exception child class only throw check exception)
                (if parent class overridding method throw exception child class only throw same as parent,samelevel,chlid exception)
            4. to inherted abstract class its methods also to be inherted
            5. implement ka sab methods ko run karna paray ga
            6. synchronized/strictfp can also run "

        donot ::
            "1. final methods
            2. static method
            3. private method"
        

    automatic promotion :::
        "byte - short - int 
        char - int 
        int - float , double , long
        float - double
        long - float , double
        int - float - boolean"

    object :::
        "object is the parent class of all the classes
        ( the compile perfer child class to call it first )"

    varargs :::
        "used for multiple arguments
        ( it has least property if no method match than it will run )"


difference method overloading and overridding :::
    method overloading :::
        1. same name 
        2. same class 
        3. different arguments ( no.of arg , type of arg , seq of arg )

    method overridding :::
        1. same name 
        2. different class
        3. same arguments ( no.of arg , type of arg , seq of arg )
        4. is-a relationship ( inheritance )


achieve by programing :::

    method overloading :::
            class test {
                void show (){
                    sout("1")
                }
                void show(int a){
                    sout("2")
                }
                psvm(String[] args){
                    test test = new test();
                    test.show();
                }
            }

    
    method overridding  :::
            class test {
                void show(){
                    sout("1")
                }
            }
            class xyz extends test {
                void show(){
                    sout("2")
                }
                psvm(String[] args){
                    test test = new test();
                    test.show()              -- it will call its own method

                    xyz xyz = new xyz();
                    xyz.show()               -- it will call its own method
                }
            }


invoking the overridding method from subclass :::
    by using "super" keywoard we can run the parent overridding method

        class test {
            void show(){
                sout("1")
            }
        }
        class xyz extends test {
            void show(){
                super.show()
                sout("2")
            }
            psvm(String[] args){
                test test = new test();
                test.show()              -- it will call its own method

                xyz xyz = new xyz();
                xyz.show()               -- it will call its own method
            }
        }
java opp
to inherite all properties of parent class into itself is called inheritance
it is alse kown as "is-a" relationship 

types of inheritance supported by java :::
    1. single      (one class pro to other) 
    2. multilevel  (one class pro to a and a class to b class pro to another)
    3. hierarical  (one class pro to a class and b class)


Java相关代码片段

Thread mutex

env files in spring boot

java over loading

logging in spring boot

how to split a list in multiple lists java

can two servlet have same urlpattern

spring debug

jsp spring

hanoi tower recursion java

java equals

age difference java

sed cheat sheet

java compare method

how to make a activity default in manifest

java max memory size

yum uninstall java

timestamp to long java

how to set background image in android studio

simple calculator in android

When to use HashMap vs Map

spring boot jpa

spring data jpa

spring jdbc

jpa vs hibernate

java with checking the password matching

profile in spring boot

string templates java

spring rest controller

java arraylist get item

com.oracle.jdbc

check if map is not empty java

how to install java 8 on debian 12

regex caractères spéciaux java

java 11 yum install

manage session in redis spring boot

java: error: release version 19 not supported

bean scope in spring

xml configuration in spring

spring cdi annotations

postconstruct and predestroy in spring

java decode_message

spring lazy initialization

java decorator design pattern

dependency injection in spring

check back pressed in fragment andorid

send email to any domain using java

record java

vs code setup for input/output in java

substring java

receive second word in string java

loose coupling in java

default value of char in java

spring boot repository pattern

spring boot h2 database

add security to spring admin

java islessthan method

Java implementation of recursive Binary Search

java round double

java downcasting

range of fibonacci series in java using recursion

java by anyone

solid java

equals() and hashcode() methods in java

android java map to bundle

android start activity with data

medium java 17

java import util list

bean life cycle in spring

spring boot aop

spring aspect

spring logging

simple java jsp project example

spring boot file watcher implementation example

kotlin loop list

autowired spring

java generics example

spring bean scope

appconfig spring

queue java array

create nan variable java