Java Polymorphism
Polymorphism: It is the ability to differentiate between entities with the same name efficiently.
Compile-time polymorphism: Static polymorphism, also called compile-time polymorphism, is achieved through function overloading in Java. Static polymorphism, also called compile-time polymorphism, is achieved through function overloading in Java.
Method Overloading: If there are multiple functions that have the same name but different parameters, it is known as overloading. Alterations in the number or type of arguments can result in the overloading of functions.
Example:
Java
// Java Program to demonstrate // Polymorphism import java.io.*; // Class class ABC { // Sum Method with int returning value public int sum( int x, int y) { return x + y; } // Sum Method with float returning value public double sum( double x, double y) { return x + y; } } // Driver Class class GFG { // main function public static void main(String[] args) { ABC temp = new ABC(); System.out.println(temp.sum( 1 , 2 )); System.out.println(temp.sum( 3.14 , 4.23 )); } } |
3 7.370000000000001
Java Cheat Sheet
Java is a programming language and platform that has been widely used since its development by James Gosling in 1982. It follows the Object-oriented Programming concept and can run programs written in any programming language. Java is a high-level, object-oriented, secure, robust, platform-independent, multithreaded, and portable programming language All those words are collectively called Java Buzzwords. It is commonly used for programming web-based, window, enterprise, and mobile applications. This Java Cheat Sheet article has been written by experts in Java and based on the experience of students who have recently undergone Java interviews.
This Core Java Cheat Sheet has been designed by Java experts, based on the experience of students who have recently undergone Java interviews. Whether you are a beginner or an experienced Java developer, this Java Cheat Sheet is a valuable resource for quickly accessing essential syntax, concepts, and best practices related to Java Programming.