1 / 38

Inheritance in Java | Types of Inheritance | Inheritance Explained | Java Tutorial | Simplilearn

Inheritance in Java is one of the primary keys to unlocking the object-oriented programming approach to design software. This tutorial here will help you learn the fundamentals of Inheritance in Java through some exciting real-time examples <br><br>About Simplilearn Java certification training course:<br>If youu2019re looking to master web application development for virtually any computing platform, this Java Certification Training course is for you. This all-in-one Java training will give you a firm foundation in Java, the most commonly used programming language in software development.<br><br><br>This advanced Java Certification Training course is designed to guide you through the concepts of Java from introductory techniques to advanced programming skills. The course will provide you with the knowledge of Core Java 8, operators, arrays, loops, methods, and constructors while giving you hands-on experience in JDBC and JUnit framework.<br><br><br>Java Certification Course Key Features:<br>1. 70 hours of blended training<br>2. Hands-on coding and implementation of two web-based projects<br>3. Includes Hibernate and Spring frameworks<br>4. 35 coding-related exercises on Core Java 8<br>5. Lifetime access to self-paced learning<br>6. Flexibility to choose classes<br><br><br>Eligibility:<br>Simplilearnu2019s Java Certification Training course is ideal for software developers, web designers, programming enthusiasts, engineering graduates, and students or professionals who wish to become Java developers.<br><br><br>Pre-requisites:<br>Prior knowledge of Core Java is a prerequisite to taking this advanced Java Certification training course. Our Core Java online self-paced course is available for free to become familiar with the basics of Java programming.<br><br><br>uf449Learn more at: https://bit.ly/3b6SCvp<br>

Simplilearn
Download Presentation

Inheritance in Java | Types of Inheritance | Inheritance Explained | Java Tutorial | Simplilearn

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agenda Why do we need inheritance? What is Inheritance? Components of Inheritance Diamond Problem Extend Keyword IS-A Relation Access Modifiers HAS-A Relation Super Keyword Types of Inheritance

  2. What is Inheritance?

  3. Click here to watch the video

  4. What is Inheritance? Inheritance is an act through which a new class gets created by acquiring the variables and methods defined in the previous(parent class).

  5. What is Inheritance? Food() Fruits() Veggies() Noodles()

  6. Why do we need Inheritance?

  7. Why do we need Inheritance? We implement Inheritance for multiple reasons. Like: Creating a possibility to add or remove features. To reduce the code length as we reuse the code. More comfortable to develop and maintain the Project.

  8. Why do we need Inheritance? Call() SMS()

  9. Why do we need Inheritance? Media() Call() SMS() Browse()

  10. Why do we need Inheritance? Call() SMS() Media() Call() SMS() Browse()

  11. Why do we need Inheritance? Call() SMS() Inherit Media() Browse()

  12. Components of Inheritance

  13. Components of Inheritance Inheritance has two major components, those are mentioned as follows: Parent class/Super class Child class/Sub class Parent Class Child Class

  14. Extends Keyword

  15. Extends Keyword The term “extends” is a predefined keyword in java, that allows you to create a new child class by deriving the variables and methods from the parent class to reduce code length and improve the performance.

  16. Access Modifiers

  17. Access Modifiers Access Modifiers Private Public Protected Default

  18. Access Modifiers Default Default Access Modifier is set implicitly whenever you declare a class without a specific access modifier. By default, the access of a class or method, when declared without a specific access modifier, becomes available to any other method or class within the same package,

  19. Access Modifiers Public A certain class can be declared as Public by using the keyword “public.” Any class or method when declared as public, becomes available to any class or method declared in the same package, but if a different method or class needs it, it should be imported

  20. Access Modifiers Protected A certain class is declared protected by using the keyword “protected.” This provides access to methods and variables of the protected class only to the rightful subclasses and protects the data from any other classes which are not related.

  21. Access Modifiers Private A certain class is declared protected by using the keyword “private.” This provides the ultimate protection to the data members and the methods of the private class. This procedure is implemented by class to encapsulate the methods and members.

  22. Super Keyword

  23. Super Keyword Super Keyword eliminates the confusion between parent class method and subclass method. Super keyword is implemented to access a method or constructor that is defined in the parent class

  24. Types of Inheritance

  25. Types of Inheritance A A A A B B B C D B C C D Hierarchal Inheritance Hybrid Inheritance Single Inheritance Multi-Level Inheritance

  26. Types of Inheritance A Single Inheritance consists of one parent class and one child class. Here, child class inherits parent class methods and data members. B Single Inheritance

  27. Types of Inheritance A Multi-Level inheritance is also a parent child inheritance relation but the difference is the child class is inherited by another child class. B C Multi-Level Inheritance

  28. Types of Inheritance A Hierarchical Inheritance is a parent child relationship. The only difference is, here, multiple child classes inherit one parent class. B C D Hierarchical Inheritance

  29. Types of Inheritance A The name itself explains us all. The Hybrid Inheritance can be a combination of any of the three types of inheritances supported in Java. B C D Hybrid Inheritance

  30. Diamond Problem

  31. Diamond Problem A Java programming Language does not support Multiple Inheritance as it ends up with a serious ambiguity. B C D Diamond Problem

  32. IS-A Relation

  33. IS-A Relation Fruit IS-A When a class inherits methods and members from a different class, then the relation is said to be an IS-A Relation. Example: Orange IS-A Fruit. HAS-A Orange Citrus Taste

  34. HAS-A Relation

  35. HAS-A Relation Fruit IS-A When a class inherits an instance from a different class or an instance or its own class, then the relation is a HAS-A type. Example: Orange HAS-A Citrus Taste. HAS-A Orange Citrus Taste

  36. Q&A Session

More Related