Posts

Encapsulation in java. In English

Image
                                                          Encapsulation Java encapsulation is the technique of combining data and code into a single entity, such as a capsule containing a combination of medications.  Making each and every one of the class's data members private allows us to construct a fully enclosed Java class. We can now set and retrieve the data in it using the setter and getter methods. A fundamental concept in object-oriented programming (OOP) is encapsulation, which in Java refers to the grouping of data and methods that manipulate that data into a single unit known as a class. Java encapsulation is a technique for restricting access to a class's implementation details such that only the public interface—which is used to communicate with the class—is visible to outside parties. Data encapsulation is the process of gr...

Interface in Java. In English

Image
                                     Interface In Java, an interface is a class's blueprint. It features abstract methods and static constants. Java's interface is a tool for achieving abstraction. The Java interface can only include abstract methods; method bodies are not allowed. In Java, it's utilized to accomplish multiple inheritance and abstraction. Stated differently, it is possible for interfaces to contain abstract variables and methods. There can be no method body for it.  The IS-A relationship is also represented via the Java Interface. Similar to the abstract class, it cannot be instantiated. An interface may contain both static and default methods. An interface may contain private methods. Utilizing an interface is primarily done for three reasons. It is used to achieve abstraction. By interface, we can support the functionality of multiple inheritance. It can be us...

Abstraction in java. In English

Image
                                            Abstraction Another way to describe data abstraction is the act of focusing just on an object's necessary features while ignoring its extraneous aspects. An object's characteristics and actions set it apart from other objects of the same type and aid in classifying and organizing the objects. Java's abstract classes and interfaces allow for abstraction. Using interfaces, we can achieve 100% abstraction. Java Abstract classes: -   A class declared using the abstract keyword is known as an abstract class. All abstract methods may or may not be included in an abstract class. Some of them might be practical techniques. No object of an abstract class is possible. In other words, the new operator cannot be used to instantiate an abstract class directly. The default constructor is always present in an abstract class, however paramet...

Polymorphism in Java. In English

Image
                                                  Polymorphism In Java, polymorphism is the idea that allows us to execute a single action in multiple ways. The words poly and morphs are both Greek words. The definition of "morphs" is shapes, while "poly" means many. Hence, polymorphism refers to variety. One of the key components of object-oriented programming is polymorphism. After a subclass overrides a superclass method, polymorphism is the process of uploading and implementing subclass methods through the superclass reference. There are two types of polymorphism in Java. 1.Compile-time polymorphism 2.Runtime polymorphism Compile-time polymorphism...................... Another name for it is static polymorphism. Operator overloading or function overloading are the methods used to achieve this kind of polymorphism.  There are three subtypes of compile-tim...

Super keyword and Casting. In English

Image
                                    Super keyword and Casting Super keyword............ In Java, parent class objects can be referred to using the super keyword, which is a reference variable. To grasp the Java super keyword, one must have a basic understanding of inheritance and polymorphism. When inheritance was introduced, the term "super" entered the picture. To refer to the parent class of a subclass in Java, use the super keyword. Its features include the following: - The constructor of a subclass must call the constructor of its parent class when it is built; this is done using super. The parent class constructor is called via the super () keyword to do this. A subclass can use the super keyword to invoke a method defined in its parent class. When a subclass wishes to call the parent class's implementation of the method in addition to its own, this is helpful. Super is the keyword used to ac...