Types of Methods in Interfaces

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/abstract-keywords-interfaces/asset-types-of-methods-in-interfaces 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 explains the four commonly discussed types of methods in Java interfaces: abstract, default, static, and private. It begins with abstract methods, defined as declarations without a method body, demonstrated through an Animal interface with void sound() and a Dog class that implements it, producing the console output "Dog barks." The lesson then covers default methods, introduced in Java 8, which have a method body and are declared using the default keyword, such as default void eat() printing "Animal eats." Static methods are presented next; they belong to the interface itself, have a method body, and are called using the interface name rather than an object, as shown by Demo.display() printing "Hello." Private methods, introduced in Java 9, are shown with a method body and cannot be accessed directly outside the interface; the example uses private void message() called from a default method. The lecture then shifts to the advantages of interfaces, including abstraction, loose coupling, code reusability, and maintainability, illustrated with Animal and Vehicle interface examples. Finally, a comparison table contrasts abstract classes and interfaces across keywords, methods, variables, constructors, inheritance, and purpose. Side-by-side code examples both named Vehicle show that the abstract class example outputs "Car starts" and "Vehicle Stopped," while the interface example outputs only "Car starts," reinforcing the practical differences between the two constructs.

Chapters

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

    The slide titled "Types of Methods in an Interface" states that Java supports four commonly discussed types of interface methods. Section A defines an abstract method as one declared without a method body, with the code line void sound(); highlighted in a red box. The Main.java editor shows interface Animal { void sound(); }, class Dog implements Animal with public void sound() printing "Dog barks", and a Main class calling d.sound();, with the Console tab displaying "Dog barks." Red hand-drawn circles highlight void sound();, the sound() body, and d.sound();, with an arrow pointing to the console output.

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

    Section B introduces the default method, described as having a method body and being declared using the default keyword, with a note that it is introduced in Java 8. The code example shows default void eat() { System.out.println("Animal eats"); } and console output "Animal eats", with a comment noting that Dog can use the default method without overriding it. The lesson then transitions to static methods, which belong to the interface itself and have a method body. The Demo interface example includes static void display(), called as Demo.display(); using the interface name rather than an object, with console output showing "Animal eats" and "Hello." Red annotations emphasize the default and static keywords and the method calls.

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

    Section D covers the private method, which has a method body and was introduced in Java 9. An Important note states it cannot be accessed directly outside the interface. The Main.java editor shows interface Demo containing private void message() printing "Hello", a default void display() calling message(), a Main class instantiating DemoImpl, and class DemoImpl implements Demo, with the console displaying "Hello". The instructor is visible in the lower-right corner gesturing throughout. The lesson then moves to a slide titled "Advantages of an Interface" with four quadrants: Abstraction, Loose Coupling, Code Reusability, and Maintainability, illustrated with interface Animal { void sound(); } and interface Vehicle { void start(); }. Red digital ink underlines and circles key terms and code snippets, and the section transitions to a comparison table titled "Difference between Abstract Class & Interface".

  4. 10:00 – 12:49 10:00-12:49

    The comparison table contrasts abstract classes and interfaces across keywords, methods, variables, constructors, inheritance, and purpose. Red annotations highlight abstract and concrete methods in the abstract class column, and abstract, default, and static methods in the interface column. Circled annotations emphasize "only one" for inheritance versus "multiple interfaces", and "common state and behavior" for purpose. The final section shows side-by-side code panels both named Vehicle: the left "Example of Abstract Class" outputs "Car starts" and "Vehicle Stopped", while the right "Example of Interface" outputs only "Car starts". Red handwritten annotations include checkmarks, arrows, underlines, and a circle around c.start(); in the right panel.

The lecture follows a clear pedagogical sequence: it first defines each of the four interface method types with a concise textual definition followed by a runnable code example and console output, allowing students to connect syntax to behavior. Abstract methods establish the baseline contract, default methods show how interfaces can provide optional behavior since Java 8, static methods demonstrate interface-level utility methods called by interface name, and private methods illustrate Java 9 encapsulation within interfaces. The instructor consistently uses red annotations to draw attention to keywords and method calls, reinforcing the syntactic markers that distinguish each type. The second half of the lecture broadens the scope from method types to the strategic value of interfaces, listing abstraction, loose coupling, code reusability, and maintainability as advantages. The comparison table then consolidates the distinction between abstract classes and interfaces, and the final side-by-side Vehicle examples make the difference concrete: the abstract class can include a concrete stop() method producing "Vehicle Stopped", while the interface example produces only "Car starts", underscoring that interfaces define contracts without necessarily providing shared state or concrete behavior. This progression from syntax to rationale to comparative analysis supports exam preparation by covering definitions, examples, and conceptual distinctions.

Loading lesson…