Inheritance
Breakdown of Inheritance for QA Automation Engineers
.
.
(Read the post Step by Step)
Concept that allows new classes (subclasses) to inherit properties and behaviors from existing
classes (superclasses)
⭐ Key Concepts:
Superclass: The parent class containing shared properties and methods
Subclass: The child class inheriting from the superclass and potentially adding its own properties
and methods
Inheritance Hierarchy: A tree-like structure showing inheritance relationships between classes
Extends Keyword: Declares a subclass by following the superclass name with extends
Method Overriding: Subclass redefines a method inherited from the superclass with its own
implementation
Access Modifiers: control the visibility and accessibility of classes, methods, variables, and
constructors
Types? ❓
Public: Members are accessible from anywhere in the program, regardless of package or class
Private: Members are only accessible within the same class. They are hidden from other classes
and packages
Protected: Members are accessible from within the same class, subclasses of that class within
same package
Default (no modifier): Members without any access modifier are accessible within the same
package they are declared in
⭐ Types of Inheritance in JAVA:
Single Inheritance: A subclass inherits from a single parent class, gaining access to its members
and potentially overriding them
Multilevel Inheritance: A subclass inherits from another subclass, forming a chain of inheritance
Hierarchical Inheritance: Multiple subclasses inherit from a single parent class, but not from each
other
Hybrid Inheritance (not directly supported in Java): Combines multiple inheritance techniques like
multilevel and hierarchical. While not directly supported due to potential ambiguity issues known
as "Diamond Problem"
✨ Important (for interviews) ⬇
Interfaces for multiple inheritance: If you need functionality from multiple sources, explore using
interfaces. Unlike classes, a class can implement multiple interfaces effectively achieving a form of
multiple inheritance.
-x-x-
My E-Books:
E-Books and cheat sheets package: https://lnkd.in/gusymgFi
QA & Automation Interview Prep Package for 2024: https://lnkd.in/gcWuCJmr
Improve your personal finance and focus on wealth creation: Personal Finance E-Book with
Japneet Sachdeva (topmate.io)
My Courses:
Full Stack QA & Automation Course with E-Books and CheatSheets: https://lnkd.in/dWjpT3-3
QA, UI & API Automation Course: https://lnkd.in/d35-Cbsd
Other Important Links:
If you need 1on1 sessions with me then you can use - https://lnkd.in/dcDtHp2r
My YouTube Videos - https://lnkd.in/guBKkQVv
My Medium Articles - https://lnkd.in/dCDi84Q9
My GitHub - https://lnkd.in/dy7AQD8f
hashtag#japneetsachdeva