Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hi, This is very nice article. I 've one question. In below code from which version of the “method()” method called. interface Rollable { void method(); } interface bounceback extends Tyre { int BAR=9; void rollaback_of_Rollable(); void method(); } interface bounceback1 extends bounceback,Rollable,Tyre { abstract void rollaback_of_bounceback1(); public static final int BAR=10; void method(); } class Demo extends abclass implements bounceback1 { @Override public void rollaback_of_bounceback1() { System.out.println(“Method rollaback_of_bounceback1 BAR::”+BAR); } @Override public void rollaback_of_Rollable() { System.out.println(“Method rollaback_of_Rollable BAR::”+BAR); } static String method1() { return “Method method1_Demo BAR::”+BAR; } @Override public void method() { System.out.println(“--------Method ------------”); } // @Override //public void method() { //} } public class InterfaceDemo { /** * This class demonstrates the interface */ public static void main(String[] args) { Demo demo=new Demo(); demo.rollaback_of_Rollable(); demo.method(); }//end of method }//end of class
- maitrey
hi guyss…!!! i have some problem in java program … i’m student of BCA… can u plz give me the coding of this program… Q:- WAP for constructor with arguments in java…?? plz if u guyss have sufficient answer than plz rply me…:)
- Guramandeep Kaur
In important points: Interfaces can’t have constructors because we can’t instantiate them and interfaces can’t have a method with body. Confused with the above statement: If Constructors are depend on the instantiation, then why abstract class can contain constructors? Abstract class also cannot be instantiated.
- Raghuveer Kurdi
Thanks, your article is very useful and unique, because illustrates the reasons for using interfaces perfectly.
- Mohammed
In java, an interface is a blueprint of a class. It has provide only static constants and abstract methods in java.The interface is a mechanism to achieve fully abstraction. There can be only abstract methods in interface, not method body. An Interface is used to achieve fully abstraction and multiple inheritance in Java.Java Interface represents IS-A relationship. Interface is also not be instantiated just like abstract class.By default, Interface fields are public, static and final and methods are public abstract in java.
- RoyJain
PLS DO HELP ME!!!..It sayz “Shape is not abstract and does not override abstract method circum_circle() in Circle.”“” import java.util.*; import java.lang.*; interface Circle{ void area_circle(); void circum_circle(); } interface Square{ void area_square(); void circum_square(); } interface Rectangle{ void area_rect(); void circum_rect(); } class Shapes implements Circle,Square,Rectangle{ public void area_circle(int r){ double area=3.14*Math.sqrt®; System.out.println(“Area of Circle :”+ area); } public void circum_circle(int r){ double circum=6.28*r; System.out.println(“Circumference of Circle :”+ circum); } public void area_square(int a){ int area=a*a; System.out.println(“Area of Square :”+ area); } public void circum_square(int a){ int circum=4*a; System.out.println(“Circumference of Square :”+ circum); } public void area_rect(int l,int b){ int area=l*b; System.out.println(“Area of Rectangle :”+ area); } public void circum_rect(int l,int b){ int circum=2*l+b; System.out.println(“Circumference of Rectangle :”+ circum); } } class ShapesTest{ public static void main(String args[]){ Shapes sh=new Shapes(); sh.area_circle(3); sh.circum_circle(3); sh.area_square(4); sh.circum_square(4); sh.area_rect(10,20); sh.circum_rect(10,20); } }
- asha
Hi, Pankaj I dont understand interfaces! how does interfaces support code reusability when interface dont have any definition (only declaration) and the fact that anyways we’ve to write a definition in the class which we are using to implement interfaces ? why we need extra code of interface… and if we want to use the same behavior then we can call that method by creating that class object… please help me with proper example of interface… Thanks, Gandhimathi
- Gandhimathi
@Asha import java.util.*; import java.lang.*; interface Circle{ void area_circle(); void circum_circle(); } interface Square{ void area_square(); void circum_square(); } interface Rectangle{ void area_rect(); void circum_rect(); } class Shapes implements Circle,Square,Rectangle{ public void area_circle(int r){ double area=3.14*Math.sqrt®; System.out.println(“Area of Circle :”+ area); } public void circum_circle(int r){ double circum=6.28*r; System.out.println(“Circumference of Circle :”+ circum); } public void area_square(int a){ int area=a*a; System.out.println(“Area of Square :”+ area); } public void circum_square(int a){ int circum=4*a; System.out.println(“Circumference of Square :”+ circum); } public void area_rect(int l,int b){ int area=l*b; System.out.println(“Area of Rectangle :”+ area); } public void circum_rect(int l,int b){ int circum=2*l+b; System.out.println(“Circumference of Rectangle :”+ circum); } } class ShapesTest{ public static void main(String args[]){ Shapes sh=new Shapes(); sh.area_circle(3); sh.circum_circle(3); sh.area_square(4); sh.circum_square(4); sh.area_rect(10,20); sh.circum_rect(10,20); } } You have to implement all the unimplemented methods from all the interfaces. like … @Override public void area_rect() { } @Override public void circum_rect() { } @Override public void area_square() { } @Override public void circum_square() { } @Override public void area_circle() { } @Override public void circum_circle() { }
- APPPYA