Abstract In Interface Java Code Example


Example 1: abstract classes and interfaces in java

abstract class have no implementation of methods functions inside it. the classes which extending abstract class have to implement it

Example 2: abstract class example in java

//abstract parent class abstract class Animal{    //abstract method    public abstract void sound(); } //Dog class extends Animal class public class Dog extends Animal{     public void sound(){ 	System.out.println("Woof");    }    public static void main(String args[]){ 	Animal obj = new Dog(); 	obj.sound();    } }

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable