Please enable JavaScript.
Coggle requires JavaScript to display documents.
JAVA - Coggle Diagram
JAVA
OOPS
POLYMORPHISM
The word ‘polymorphism’ means ‘having many forms’. In simple words, we can define Java Polymorphism as the ability of a message to be displayed in more than one form.
-
Runtime Polymorphism
Runtime polymorphism in Java, also known as dynamic method dispatch, is a concept that allows a method or function to behave differently based on the object it's acting on:
ENCAPSULATION
The binding of data (attributes) and methods that operate on that data within a single unit (class). This protects data integrity and provides controlled access to the class internal state.
INHERITANCE
-
-
-
Hybrid Inheritance
A combination of multiple and multilevel inheritance. it's a complex structure not directly supported by java classes but can be achieved using interfaces
A mechanism where a new class (subclass) acquires the properties and behaviours of a n existing class (superclass). This promotes code reusability and a hierarchical organization of classes.
ABSTRACTION
Abstraction in Java refers to hiding the implementation details of a code and exposing only the necessary information to the user
Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class).
Abstract method: can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from).
Interface
Interfaces are another method of implementing abstraction in Java. The key difference is that, by using interfaces, we can achieve 100% abstraction in Java classes.
To access the interface methods, the interface must be "implemented" (kinda like inherited) by another class with the implements keyword (instead of extends). The body of the interface method is provided by the "implement" class:
Arrays & ArrayList
Array
Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.
Syntax : String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
syntax for intiger : int[] myNum = {10, 20, 30, 40};
ArrayList
-
The difference between a built-in array and an ArrayList in Java, is that the size of an array cannot be modified (if you want to add or remove elements to/from an array, you have to create a new one). While elements can be added and removed from an ArrayList whenever you want. The syntax is also slightly different