* Low Cohesion: In the following code, we have a class called Book. But it is less cohesive because it comprises less focussed and independent attributes and methods to the class. This class should contain information related to the Book. Therefore, the person's name and age method are making this classless cohesive.
#Source_code
#Cohesion_In_Java
#Low_Cohesion
#OOP_Concepts_java
#121
#Source_code
#Cohesion_In_Java
#Low_Cohesion
#OOP_Concepts_java
#121
code.png
410.4 KB
Association is relation between two separate classes that establishes with the help of their Object.
#Source_code
#OOP_Concepts_java
#Association_in_java
#123
#Source_code
#OOP_Concepts_java
#Association_in_java
#123
A method that has the static keyword in the declaration is known as the static method. In other words, a method that belongs to a class rather than an instance of a class is known as a static method. We can also create a static method by using the keyword static before the method name. The main benefit of a static method is that we can invoke the static method without even creating an object. It can access static data members and also change their values and is also used to create an instance method. The main() method is a common example of the static method.
#Source_code
#OOP_Concepts_java
#Static_method_in_java
#126
#Source_code
#OOP_Concepts_java
#Static_method_in_java
#126
A method that is declared final is called a final method. We cannot override a final method. This means the child class can still call the final method of the parent class without any problem, but it cannot override it. This is because the main purpose of making a method final is to stop the modification of the method by the sub-class.
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#128
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#128
Java
A method that is declared final is called a final method. We cannot override a final method. This means the child class can still call the final method of the parent class without any problem, but it cannot override it. This is because the main purpose of…
Instead of modifying the method, we can use it as shown:
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#129
#Source_code
#OOP_Concepts_java
#Final_Method_in_java
#129