
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
Inheritance
Inheritance is the ability of a subclass to take on the general properties of superclasses in the inheritance chain. The properties then form part of the subclass’ definition. Inheritance enables superclasses’ properties to be propagated downward to the subclasses in a class hierarchy, and makes the properties available as part of the subclasses’ definition. These properties are said to be inherited (or taken on) by the subclasses.
Inheritance is a process of defining a new class based on an existing class by extending its common data members and methods.
Inheritance allows us to reuse of code, it improves reusability in your java application.
Syntax
class XYZ extends ABC { }
Example
class Developer { String designation = "Developer"; String companyName = "Ducat"; void does(){ System.out.println("IT Sector"); } } public class PhpDeveloper extends Developer{ String mainSector = "Php"; public static void main(String args[]){ PhpDeveloper obj = new PhpDeveloper(); System.out.println(obj.companyName); System.out.println(obj.designation); obj.does(); } }
Output
Ducat
Developer
Php
IT sector
In above example, we have a base class Developer and a sub class PhpDeveloper. Since class PhpDeveloper extends the designation and company properties and work() method from base class, we need not to declare these properties and method in sub class.
Here we have companyName, designation and work() method which are common to all the Developers so we have declared them in the base class, this way the child classes like JavaDeveloper, WordPressDeveloper and HtmlDeveloper do not need to write this code and can be used directly from base class.
Example 2
class Developer { private String designation = "Developer"; private String companyName = "Ducat"; public String getDesignation() { return designation; } protected void setDesignation(String designation) { this.designation = designation; } protected String getCompanyName() { return companyName; } protected void setCompanyName(String companyName) { this.companyName = companyName; } void does(){ System.out.println("IT sector"); } } public class JavaExample extends Developer{ String mainSector = "Php"; public static void main(String args[]){ JavaExample obj = new JavaExample(); /* Note: we are not accessing the data members * directly we are using public getter method * to access the private members of parent class */ System.out.println(obj.getCompanyName()); System.out.println(obj.getDesignation()); System.out.println(obj.mainSector); obj.does(); } }
Output
Ducat
Developer
Php
IT sector
In Example 2, the important point to note in the above example is that the child class is able to access the private members of parent class through protected methods of parent class. When we make a instance variable (data member) or method protected, this means that they are accessible only in the class itself and in child class.
Types of Inheritance
Types of Inheritance in Java
- Single Inheritance
- Multilevel inheritance
- Hierarchical inheritance
- Multiple Inheritance
- Hybrid inheritance
Single Inheritance
Single inheritance refers to child and parent class relationship. In Single inheritance class extends another class.
Multilevel Inheritance
Multilevel inheritance refers to child and parent class relationship. In Multilevel inheritance class extends the child class. Like class C extends class B extends class A.
Hierarchical Inheritance
Hierarchical inheritance refers to child and parent class relationship. In Hierarchical inheritance, more than one classes extends the same class. Like classes B, C, D extends the same class A.
Multiple Inheritance
In Multiple Inheritance refers to one class extends more than one classes means one child class has two parent class. Like class C extends both class A and B. But in Java it does not support multiple inheritance.
Hybrid Inheritance
Combination of more than one types of inheritance in a single program. For example class A & B extends class C and another class D extends class A then this is a hybrid inheritance example because it is a combination of single and hierarchical inheritance.
Apply now for Advanced Java Training Course