Method
1.It is a member function with a different name than the class name, which is user-defined.
2.HAs a valid return type or void.
3.Used to perform operations on variables/constants.
Constructor
1.It is a member function with the same name as that of the class name.
2.Has no return type not even void.
3.Used to give default/initial values to instance variables.
if-else-if
1. It is used to compare a range of values or to perform logical/relational or equality operations.
2.Works with all primitve data types.
3.If all conditions are false, else is executed.
switch-case
1.It is used to compare values for equality only.
2.Works with integer datatypes or character datatype only.
3.If all conditions are false, default is executed.
slimshady21
|