Multiple Interitance in Java

Duration: 13 min

This video lesson is available to enrolled students.

Return to /learn/ASRB-ICAR-T3-T4-INFORMATION-TECHNOLOGY-PRELIMS-MAINS/oops-with-c-java/oops-with-java/inheritance/asset-multiple-interitance-in-java after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Prelims: General Knowledge: Physics Chemistry Biology History Geography Polity Indian Economy Static General Knowledge GK- Current Affairs Environment
  2. Prelims: General English: Vocabulary Noun Pronoun Adjectives Preposition Articles Direct and Indirect Speech Tenses Conjunction Subject Verb Agreement (Verb Noun Agreement) Modals Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing) Sentence Correction (Error Correction) Sentence Completion (Fill in the blanks) Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions) Cloze Test (Cloze Passage) Verbal Analogy (Word Based Analogy) Sentence Construction Adverb Verb
  3. Prelims: Quantitative Aptitude: Percentage Ratio and Proportion (Ratios) HCF LCM Divisibility Rules Average Sequence and Series (Series) Number System Powers and Exponents (Surds and Indices) Algebra Profit and Loss Simple Interest and Compound Interest Time and Work Pipe and Cistern Speed Time and Distance Mixture and Alligation Mensuration and Geometry Age Problems Partnership Statistics Data Interpretation Arithmetic
  4. Prelims: General Agriculture: Agriculture in India and Tripura Natural Resource Management Fundamentals of Crop Production Horticulture Crop Improvement Crop Protection Social Science
  5. IT Mains: Operating System: Introduction to OS Process Management CPU Scheduling Process Synchronization Threads & Process Creation Deadlock Memory Management Virtual Memory Disc Scheduling File Management Distributed Systems
  6. IT Mains: Computer Networking: Introduction to CN DLL: Access Control DLL: Flow Control DLL: Error Control Data Link Layer - Ethernet Net Layer: IPv4 & Proto Net Layer: IP Addressing Net Layer:Routing Protocol Transport Layer Services TL: Congestion & UDP Application Layer Hardware Basics Network Security
  7. IT Mains: DBMS: Basics of DBMS ER Diagram Relational Model & Functional Dependencies Keys & Integrity Constraints Normalization (1NF - BCNF) Decomposition Properties & 4NF Relational Algebra SQL Relational Calculus Transaction Management Concurrency Control Database Recovery Big Data Systems Database Security & Authorization Enhanced Data Models NoSQL
  8. IT Mains: Software Engineering: Fundamentals of Software Engineering Software Requirements and Quality Assurance Software Design, Estimation and Metrics Software Testing Software Maintenance and Configuration Management
  9. IT Mains: Data Structures & Algorithms: Introduction to DS Array Stack Queue Linked List Tree Graphs Hashing Algorithm Analysis Time Complexity Analysis Sorting Algorithms
  10. IT Mains: OOPS with C++ & Java: C Fundamentals OOPS with C++ Java Fundamentals Array, String, IO & References OOPS with Java Generic & Collections Multithreading File Handling & I/O
  11. IT Mains: Python: Introduction to Python Tokens, Variables, Data Types, I/O Operators & Expressions Control Flow & Looping Collections & Strings Functions & Modules
  12. IT Mains: Website Development: Website, Browser & Services Internet Fundamentals Web Design & Development Protocols & Services Web Publishing & Hosting Server Side & Security Emerging Technologies HTML Basics HTML5 CSS JavaScript-Basics .Net Programming PHP
  13. IT Mains: Mobile App Development: Mobile Computing Multimedia
  14. IT Mains: Linux / Windows Server Admin: Unix OS Linux OS
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture introduces multiple inheritance in Java, defining it as a single child class inheriting from more than one parent class. The instructor explains that Java forbids this for classes, producing a compile-time error, primarily due to the Diamond Problem. A diagram shows Class C inheriting from Class A and Class B, both containing a method named show(). When c.show() is called, the compiler cannot determine which parent's method to execute, creating ambiguity. The lesson then shifts to how Java achieves multiple inheritance through interfaces. Interfaces contain only method names without a body, so the child class must write the actual code, eliminating confusion about which parent code to run. A code example demonstrates a class Demo implementing two interfaces, Printable and Showable, with method bodies for print() and show(). The console output confirms both methods execute correctly. The final segment briefly introduces the super keyword, which refers to the immediate parent class, using a Parent and Child class example to show how to access parent fields when names conflict.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The lecture opens by defining multiple inheritance as a scenario where one child class inherits from more than one parent class. The instructor highlights that Java does not allow this with classes, showing the code snippet 'class C extends A, B { }' marked with a compile-time error. The main reason given is the Diamond Problem, illustrated with a diagram where Class C inherits from Class A and Class B, both having a method named show(). The instructor explains that calling c.show() creates ambiguity because the compiler cannot decide which parent's method to execute.

  2. 2:00 – 5:00 02:00-05:00

    The instructor continues explaining the Diamond Problem, using a diagram to show Class C inheriting from Class A and Class B. The code example 'class C extends A, B' is written in red ink to emphasize the compile-time error. The instructor annotates the diagram with terms for 'father' and 'method' to clarify the inheritance hierarchy. The ambiguity of method resolution is stressed, showing why Java restricts multiple inheritance for classes to avoid confusion when both parents define the same method.

  3. 5:00 – 10:00 05:00-10:00

    The lesson transitions to how Java achieves multiple inheritance using interfaces. The instructor highlights that interfaces contain only method names without a body, so the child class writes the actual code, preventing confusion about which parent code to run. A code example shows a class Demo implementing two interfaces, Printable and Showable, with method bodies for print() and show(). The console output displays 'Printing...' and 'Showing...', confirming both methods execute. The instructor circles key terms like 'Interfaces' and 'actual code' to emphasize the solution.

  4. 10:00 – 13:25 10:00-13:25

    The instructor uses arrows and brackets in the code editor to link interface method declarations to their implementations in the Demo class, crossing out and highlighting specific lines to focus on the connection. The console output shows the results of calling print() and show() on a Demo instance. The final segment introduces the super keyword, which refers to the immediate parent class. A Main.java example shows a Parent class with int x = 10 and a Child class with int x = 20, using comments to distinguish between the child's x and the parent's x accessed via super.

The lecture progresses from defining multiple inheritance and explaining why Java forbids it for classes due to the Diamond Problem, to demonstrating how interfaces provide a safe alternative. The key insight is that interfaces avoid ambiguity because they lack method bodies, forcing the child class to implement the code. The final introduction of the super keyword sets up a follow-up topic on accessing parent class members when names conflict.

Loading lesson…