Advanced Java Programming

Image
                          Advanced Java Programming Advanced Java Programming :-   Introduction to advance java   As most of us already know that if we want to make normal applications it  can be easily built using core Java concepts. But, when it we need to develop web applications, advanced Java fundamentals, like JSP, Servlets, JDBC etc. needed, so to add capabilities and features of the application advance java is essential for developers. Through the motive of this blog is to explain about Advanced Java, I will be giving you a complete insight into the fundamental concepts of Advance Java. Figure - 1.2 If you want to see complete video on this please  have a look the video below.                              Learn with Resh u Advanced Java Programming Course Figure - 1.3 I hope you understood by the slide why Advanced Java is essential. For your better understanding, I have divided this article int

Interface in Java

 Interface in Java


What is Interfaces

  • Another way to achieve abstraction in Java, is with interfaces. It’s a blueprint of a class, which tells by class what to do not how to do.
  • An interface is a completely "abstract class" that is used to group related methods with empty bodies. 
Features of Interfaces

  • It is used to achieve abstraction.
  • It supports multiple inheritance.
  • It can be used to achieve loose coupling
  • Like abstract classes, interfaces cannot be used to create objects
  • Interface methods do not have a body - the body is provided by the "implement" class
  • On implementation of an interface, you must override all of its methods
  • Interface methods are by default abstract and public
  • Interface attributes are by default public, static and final
  • An interface cannot contain a constructor (as it cannot be used to create objects)
Why and When to use Interfaces

1) To achieve security - hide certain details and only show the important details of an object (interface).


2) Java does not support "multiple inheritance" (a class can only inherit from one superclass). However, it can be achieved with interfaces, because the class can implement multiple interfaces. Note: To implement multiple interfaces, separate them with a comma.
         Ex. Class A implements B, C, D{
}

Java Interface Example

In this example, the Printable interface has only one method, and its implementation is provided in the A6 class.

  1. interface printable{  
  2. void print();  
  3. }  
  4. class A6 implements printable{  
  5. public void print(){System.out.println("Hello");}  
  6.   
  7. public static void main(String args[]){  
  8. A6 obj = new A6();  
  9. obj.print();  
  10.  }  
  11. }

Output:

Hello

For Complete Explanation in Hindi Please visit My Youtube Channel




       Thanks For Watching!!!


Comments

Popular posts from this blog

Updating version numbers of modules in a multi-module Maven project

Advanced Java Programming