
Quick Contact
Java Tutorial
- What is Java?
- History of Java
- Hello Java Program
- Features of Java
- Basic Syntax
- Java Setup
- Data Types in Java
- Java Variables
- Operators in Java
- JVM
- Java If-else Statement
- Switch Case Statement
- Java Loops
- Do-While Loop
- Java While Loop
- Continue Statement
- Break Statement in Java
- Constructors in Java
- Oops Concept in Java
- Features of OOPs
- Inheritance
- Exeception handeling
- Aggregation (HAS-A relationship) in Java
- Method Overriding in Java
- Method Overloading
- Java Static Keyword
- Java This Keyword
- Java Final Keyword
- Polymorphism
- Static Binding and Dynamic Binding
- Abstract class in Java
- Access Modifiers in Java
- Difference between abstract class and interface
- Interface in Java
- Garbage Collection in Java
- Java Package
- Encapsulation
- Serialization and Deserialization in Java
- Java Inner Classes
- Java Applets
- Multithreading in Java
- Thread Priorities in Java
- Thread Creation
- Inter Thread Communication
- Wrapper Classes in Java
- Java Input Output
- Java AWT Introduction
- Java Layout Manager
- Java Layout Policy
- Java AWT Events
- Collection Framework
- Collection Framework List Interface
- Swing in Java
- Swing Utility Classes
- Swing Layout Managers
- Java JDBC
- Hibernate Framework Overview – Architecture and Basics
Springboot
- Spring Environment Setup
- Spring Boot CRUD REST API Project using IntelliJ IDEA | Postman | MySQL
- Dockerizing Spring Boot Application | Spring Boot Docker Tutorial
- spring-boot-restapidocumentation with swagger
- Spring Boot HttpClient Overview
- Apache HttpClient POST HTTP Request Example
- Apache HttpClient PUT HTTP Request Example
- Apache HttpClient DELETE HTTP Request Example
- Apache HttpClient HTML Form POST Request Example
- Spring Boot JSP Exampl
- Deploying Spring Boot WAR file with JSP to Tomcat
- Spring Boot Annotations
- Spring Core Annotations
- Spring MVC Annotations with Examples
- Spring Scheduling Annotations
- Spring - Java-based Container Configuration
- Spring Java Based Configuration Example
Hibernate
- Hibernate 5 hello world
- Hibernate- One to One Unidirectional Mapping Annotation Example
- Hibernate - Batch Processing
- Hibernate - Interceptors
- Hibernate 5 - Create, Read, Update and Delete (CRUD) Operations Example
- Hibernate Transaction Management
- Hibernate One to Many Unidirectional Mapping Example
- Hibernate One to Many Bidirectional Mapping Example
- Hibernate Many to Many Annotation Mapping Example
- Hibernate Primary KeyJoin Column
- Hibernate First Level Cache with Example
- Hibernate XML Configuration Example with Maven + Eclipse + MySQL Database
- Hibernate Java Configuration Example
- JPA 2 with Hibernate 5 Bootstrapping Example
- JPA and Hibernate Cascade Types
- Hibernate/JPA - Primary Key Generation
- Hibernate 5 - Enum Type Mapping Example
- Hibernate Component Mapping
- Hibernate Object States – Transient,Persistent and Detached
- Hibernate 5 - Save an Entity Example
- Hibernate 5 - Persist an Entity Example
- Hibernate 5 - saveOrUpdate() Method Example
- Hibernate 5 - get(), load() and byId() Method Examples
- Hibernate 5 - merge() Example
- Hibernate 5 - Delete or Remove an Entity Example
- Hibernate 5 - load() Method Example
- Hibernate Session Interface Methods
- Hibernate Session.clear() Method Example
- Introduction Of Java strutes to Architecture
- Struts 2 - Architecture
- Struts 2 - Configuration Files
- Struts 2 - Actions
- Struts 2 - Interceptors
- Struts 2 - Results & Result Types
- Struts 2 - Value Stack/OGNL
- Struts 2 - File Uploading
- Struts 2 - Database Access
- Struts 2 - Validations Framework
JAVA FX
- JavaFX Tutorial
- Introduction to JavaFX Pane
- JavaFX Popup
- JavaFX group
- JavaFX Controller
- JavaFX Gradient Color
- JavaFXAnchorPane
- JavaFXTabPane
- JavaFX Scene
- JavaFX Stage
- JavaFXWebView
- JavaFX Timeline
- JavaFX Timer
- JavaFX Image
- JavaFX Background
- JavaFX dialog
- JavaFX Font
- JavaFXTextArea
- JavaFXObservableList
- JavaFX GUI
- JavaFX FXML
- JavaFXEventHandler
- JavaFXGradle
- JavafxScrollpane
- JavaFXAPI
Method Overloading
Method Overloading, if a class has multiple methods with the same name but different parameters, it is called Method Overloading.
Overloading allows us to use functions or methods with the same name, but different arguments.
It is a way through which Java supports polymorphism. Polymorphism deals with multiple form, and it is a concept of object-oriented programming.
By changing a several arguments or changing data types of argument method overloading can be done. In method overloading, it increases the readability of the program.
The java compiler distinguishes amongst overloaded methods based on their parameter list: the methods return type is not considered when overloaded. Thus the two method declarations that follow are not overloaded because they have the same signature; they will generate a compiler error.
public void myPrintMethod( int someValue) {}
and
public int myPrintMethod( int someOtherValue ) {}
The compiler highlights the second method declaration and outputs the message:
myPrintMethod already defined. In other words, the compiler cannot distinguish between the two methods.
Different ways of method overloading.
- The Different data type of arguments
- Different number of arguments
Method overloading by changing data type of arguments.
Example
In this example, we have two sum() methods that take integer and float type arguments.
Notice that in the same class we have two methods with the same name but different types of parameters.
class Calculate { void sum (int X, int Y) { System.out.println("sum is"+(X+Y)) ; } void sum (float X, float Y) { System.out.println("sum is"+(X+Y)); } Public static void main (String[] args) { Calculate cal = new Calculate(); cal.sum (5,5); //sum(int X, int Y) is method is called. cal.sum (5.6f, 2.3f); //sum(float X, float Y) is called. } }
Output
Sum is 10
Sum is 7.9
Here sum() method is overloaded two times. First, takes two integer arguments and second, takes two float arguments.
Method overloading by changing no. of argument.
Example:
Here, we have two methods
class Test { void multiply(int X, int Y) { System.out.println("Result is"+(X*Y)) ; } void multiply(int X, int Y,int Z) { System.out.println("Result is"+(X*Y*Z)); } public static void main(String[] args) { Test ar = new Test(); ar.multiply(5,5); //multiply(int X, int Y) is method is called ar.multiply(4,3,2); //multiply(int X, int Y,int Z) is called } }
Output
Result is 25
Result is 24
Here multiply() method is overloaded twice. The first method takes two arguments, and the second method takes three arguments.
Example of Method overloading with type promotion.
In this example, we are doing the same and calling a function that takes one integer and second long type argument.
class Test2 { void sum(int X,long Y) { System.out.println("Sum is"+(X+Y)) ; } void sum(int X, int Y, int Z) { System.out.println("Sum is"+(X+Y+Z)); } public static void main (String[] args) { Test2 ar = new Test2(); ar.sum(7,3); } }
Output
Sum is 10
Overloading main Method
class TestOverloading4{ public static void main(String[] args){System.out.println("main with String[]");} public static void main(String args){System.out.println("main with String");} public static void main(){System.out.println("main without args");} }
Output
main with String[]
Apply now for Advanced Java Training Course