163 subscribers
3.42K photos
24 videos
39 files
371 links
Link: @java_posts

Contact: java.response.email@gmail.com
Download Telegram
What are Classes?
Classes are like object constructors for creating objects. The collection of objects is said to be a class. Classes are said to be logical quantities. Classes don’t consume any space in the memory. Class is also called a template of an object. Classes have members which can be fields, methods and constructors. A class has both static and instance initializers.

#Source_code
#OOP_Concepts_java
#Classes
#111
What are Classes ?
#OOP_Concepts_java
#112
What is Abstraction ?
Abstraction is a process which displays only the information needed and hides the unnecessary information. We can say that main purpose of abstraction is data hiding. Abstraction means selecting data from a large number of data to show the information needed, which helps in reducing programming complexity and efforts.
#Source_code
#OOP_Concepts_java
#Abstraction
#113
What is Inheritance ?
Inheritance is a method in which one object acquires/inherits another object’s properties, and inheritance also supports hierarchical classification. The idea behind this is that we can create new classes built on existing classes, i.e., when you inherit from an existing class, we can reuse methods and fields of the parent class. Inheritance represents the parent-child relationship.
#Explanation
#Inheritance
#OOP_Concepts_java
* Single level
In this one class i.e., the derived class inherits properties from its parental class. This enables code reusability and also adds new features to the code. Example: class b inherits properties from class a.


* Multilevel
This one class is derived from another class which is also derived from another class i.e., this class has more than one parental class, hence it is called multilevel inheritance.
#Source_code
#OOP_Concepts_java
#Inheritance
#114
* Hierarchical level
In this one parental class has two or more derived classes or we can say that two or more child classes have one parental class.

* Hybrid inheritance
This is the combination of multiple and multilevel inheritances and in java, multiple inheritances are not supported as it leads to ambiguity and this type of inheritance can only be achieved through interfaces.
#Source_code
#OOP_Concepts_java
#Inheritance
#115
What is Polymorphism?
Polymorphism refers to many forms, or it is a process that performs a single action in different ways. It occurs when we have many classes related to each other by inheritance. Polymorphism is of two different types, i.e., compile-time polymorphism and runtime polymorphism. One of the examples of Compile time polymorphism is that when we overload a static method in java. Run time polymorphism also called a dynamic method dispatch is a method in which a call to an overridden method is resolved at run time rather than compile time. In this method, the overridden method is always called through the reference variable. By using method overloading and method overriding, we can perform polymorphism. Generally, the concept of polymorphism is often expressed as one interface, and multiple methods. This reduces complexity by allowing the same interface to be used as a general class of action.
#Source_code
#OOP_Concepts_java
#Polymorphism
#117
What is Encapsulation ?
Encapsulation is one of the concepts in OOPs concepts; it is the process that binds together the data and code into a single unit and keeps both from being safe from outside interference and misuse. In this process, the data is hidden from other classes and can be accessed only through the current class’s methods. Hence, it is also known as data hiding. Encapsulation acts as a protective wrapper that prevents the code and data from being accessed by outsiders. These are controlled through a well-defined interface.
#Source_code
#OOP_Concepts_java
#Encapsulation
#118
* Tight coupling: If one class is strongly interrelated to another class, it is said to have a tight coupling with that class.
#Source_code
#OOP_Concepts_java
#coupling_in_java
#119
* Loose coupling: If one class is weakly interrelated to another class ,it is said to have loose coupling with that class. Loose coupling is preferred over tight coupling. A class can achieve this with the help of interfaces, as shows.
#Source_code
#OOP_Concepts_java
#coupling_in_java
#120
* 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
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