
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 Overriding in Java
In Method overriding if subclass is having same method as base class then it is known as method overriding Or in another words, if subclass provides specific implementation to any method which is present in its one of parents classes then it is known as method overriding.
Rule of Method Overriding
We say Method overriding if it shares these features with one of its superclass method:
- The same name.
- The same number of parameters.
- The same type of parameters.
- The same return type.
Use of Method Overriding
The key benefit to method overriding is that we can alter the behavior of the method inherited from a superclass and define its specification according to the need of the subclass.
Why method overriding is needed?
Method overriding is mainly used in a situation when we want to create a more specialized version of a generic(general) method inherited from a superclass, within the subclass.
Simple Example of Method Overriding
Below we have simple code example with one parent class and one child class wherein the child class will override the method provided by the parent class.
class X //superclass { public void name() //method name() class X { System.out.println(“Raj”); } } class Y extends X //superclass of X { public void name() //method name() of class X is overridden in class Y { System.out.println(“Abhishek”); } }
In above example, class X is inherited by class Y. The method name() of class X is returning Raj but when this method is inherited and overridden by class Y, it is returning Abhishek.
Example 2
class Car{ void run(){System.out.println("Car is running");} } class Bike extends Car{ //Creating a child class //defining the same method as in the parent class void run(){System.out.println("Bike is running safely");} public static void main(String args[]){ Bike obj = new Bike(); //creating object obj.run(); //calling object } }
Output
Bike is running safely
In above Example we define run method in child class as define in the parent class but it has specific implementation. Name and parameter are the same and here IS-A relationship between classes so there is method overriding.
Example of real scheme of java method overriding
Hear the real scheme of method overriding, there is office which provide salary to employees. The salary will give according to their designation. Example Developer, Designer, DBA(Data Base Administrator) could give 25000, 20000, and 30000.
class Office{ //creating parent class int getsalary(){return 0;} } //creating child class class Developer extends Office{ int getsalary(){return 25000;} } class Designer extends Office{ int getsalary(){return 20000;} } class DBA extends Office{ int getsalary(){return 30000;} } //Salary class to create objects and call the methods class Salary{ public static void main(String args[]){ Developer a=new Developer(); Designer b=new Designer(); DBA c=new DBA(); System.out.println("Developer Salary: "+a.getsalary()); System.out.println("Designer Salary: "+b.getsalary()); System.out.println("DBA Salary: "+c.getsalary()); } }
Output
Developer salary 25000
Designer Salary 20000
DBA salary 30000
Apply now for Advanced Java Training Course