Oops concepts in java5/16/2023 ![]() It is a distinct way to achieve association. For example, java.io is the highly cohesive package because it only has IO related classes, interfaces, and methods, whereas, java.util is a weakly cohesive package as it contains a mixture of unrelated classes and interfaces. For example, a company has many employees so it is called one to many associations.Ī component of Java which performs single and well-defined task efficiently then it is termed as cohesion. It is used to identify the bidirectional or unidirectional relationship of one object with another. We can use modifiers like public, private, and protected to define the strength of the coupling. When a class knows everything about another class then it is called Strong coupling, whereas, interface and abstract class build weak coupling with another class. It’s the level of having information of one class by another class. In Java, abstract class and interface are used to achieve abstraction. Hence, abstraction is hiding internal processing and only showing the functionality to the user. We use them but we don’t know their internal processing. ![]() There are many things which we use in real life like TV, Phone, Refrigerator, etc. For example, a draw method in Java can be used to draw different shapes like Circle, Triangle, Square, Oval, etc. Similar to that, if a task performs different activities then it is called Polymorphism. PolymorphismĪ girl plays different roles at different stages of her life, like a daughter, a sister, a wife, a nurse, etc. Similar to the above analogy, Encapsulation is the process to bind data and code together in a single class so that they can’t be accessed outside the world. When we open the capsule then we see many thin granules like medicines are enclosed within it. In real life, we sometimes take medicine in the form of a capsule. We reuse the objects through Aggregation and it develops a weak relationship between objects. It is the way to associate one object with another object and it builds a HAS-A relationship. It is used to achieve runtime polymorphism. Similarly, when a child class access data members of a parent class then it is called Inheritance in Java. We are the children of our parents and we carry some of their characteristics through genes. A class has the collection of objects and they don’t consume any memory. They are a logical entity and simply called the blueprint of the object. Two objects can communicate with each other and pass on the messages. Objects in java are the instances of the class which has the address and consumes some memory. They are the physical and logical entity that has state and behavior. Today we are going to have a glimpse over the following topics and later we will learn them in detail. Let’s discuss the OOPs concept in Java well, it simplifies the programming approach and design paradigm of the program by simply using objects and classes. ![]() As discussed earlier, an object is a real-world entity like a dog, chair, table, etc. In a nutshell, OOPs concept based programming languages are efficiently utilizing objects and classes. The reason being, programming languages like Java, Scala, C#, Python, etc are Object Oriented Programming language and they can be related to real-life entities. ![]() In this era, a simple analytical person who is proficient enough to understand algorithms can easily become a successful programmer. The earlier programming language was the language of hardware or simply machine a highly skilled programmer was needed to write a program to run on those machines. Well, let’s take the learning journey ahead therefore, today we are going to discuss the OOPs concept in Java. I hope you enjoyed reading the previous blog post on the static and final keyword in Java. ![]()
0 Comments
Leave a Reply. |