What is use of assert keyword?
R b. Be Hi mj CA g
Assertion and exception are somewhat same but you cannot disable exception and you can disable assertion when you want in your program
Assert is a keyworf which use to execuye your program and stop it when perticular condition occur. By default assertion is disabled. You have to set it enable to enable the assertion. Ex ea MyProgram. Here ea is enableassertion and MyProgram is the class name
Mostly used in junit test cases to check that your assumtion is correct or not and based on that you test your method that whether it is working as desired or not.
Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it is not true, the system will throw an error. By verifying that the boolean expression is indeed true, the assertion confirms your assumptions about the behaviour of your program, increasing your confidence that the program is free of errors.