Posts

Showing posts from February, 2024

Java OOPC - Interface

Image
  Interface Interface is keyword use in Java .Instead of using ‘class’ keyword using ‘interface’ we can create interface. As the same way creating a class we can create interface also.   Interface is also a class, but interface is not a class it work same as a class. Difference between class and interface ,interface can not   create object because of that interface even can not create constructor, But after Java 8 we can use constructors.   We can not do multiple inheritance. means that we can not inherit   more than one super class from sub class. Using extends we can not do multiple inheritance. But using the implements we can do multiple inheritance. Implements what inheritance do using the interface. So the purpose of using the interface is do the multiple inheritance. As we know we can not create the objects to the interfaces but using the upcasting we can create objects. In here object generate side be the class indeedly,   then that cla...

Java OOPC - Abstraction

Image
  Abstraction   Abstraction is that modify class or method using the ‘ abstract ’ key word. We can keep abstract method if only the class is abstract. If class is abstract there is no any difference, it is just a class. As a normal class we can work with it, means that we can use non abstract methods and variables   or anything inside the abstract class.   Meaningless we can define using the abstraction. Meaningless is that There is not any code inside the method or we can say there is not body   inside the method. In the   example, an abstract class `Animal` has been created, featuring an abstract method `makeSound()` and a non-abstract method `eat()`.   A subclass `Dog` has been derived from the superclass `Animal`. In this subclass, the abstract method `makeSound()` is implemented, providing a specific sound for a dog.   An object `d1` of the `Dog` class is then instantiated. Through this object, we invoke the methods `m...

Java OOPC -Encapsulation

Image
Encapsulation In real life capsule is based for the concept Encapsulation, We use capsule for the protection and security of the medicine that inside the capsule from   of environmental conditions and other things because that conditions generated unhealthy components.   In here when it comes to object oriented concept Encapsulation is that data hiding, protection and security. Further this concept we use for the variables.   We talk about the GET and SET methods thought the concept encapsulation,   Getters and setters   For the better security we use access modifier ‘private’   ,because in private modifier only let the specific class accessing. So private variables can use outside of the specific method using GET and SET methods.   Indeed we use private keyword for data security purpose but in some time some specific reasons we need to use those outside of the class we define it previously, Because of this reason we use getter...

Java OOPC - Polymorphism

Image
  Polymorphism     Polymorphism is the process   When Method in the sub class override the Method in the Super class, and do the upcasting after that call the   sub class method though the super class reference.   When we have multiple choices inherit the   all classes that need the super class ,after that create the meaningless method. In the end create the object as the upcasting to call sub classes. Then we can call the object for necessary data input.   Polymorphism is a fundamental concept in object-oriented programming (OOP) that allows objects of different types to be treated as objects of a common type. This not only enhances code flexibility but also promotes code reusability and maintainability.    In other simply way we can tell polymorphism as the take many forms. If we come to real world exam below show it simply. In the example, the `Calculator` class exhibits method overloading by defining multiple method...