Forum Stats

  • 3,826,671 Users
  • 2,260,688 Discussions
  • 7,897,047 Comments

Discussions

Abstrct demo not work

1033862
1033862 Member Posts: 155
edited Dec 4, 2015 10:41AM in New To Java

Dear

i want to learn abstract classes and interface, i got this code from a web, but getting error when i compile it. error is below.

error (7,24):class abstractDemp.exmple1 can not be reference from static context:

public class AbstractDemo

{

 

  public static void main(String args[]){

Example4 obj=new Example4();         --- error showing here
  obj.display3();

     

    System.out.println("display1 method");

    System.out.println("display1 aaa method");

  }

class Example1{

     public void display1(){

        System.out.println("display1 method");

     }

  }

  abstract class Example2{

     public void display2(){

        System.out.println("display2 method");

     }

  }

   

  abstract class Example3 extends Example1{

     abstract void display3();

  }

   

  class Example4 extends Example2{

     public void display3(){

        System.out.println("display3 method");

     }

  }

   

 

 

}

Answers

This discussion has been closed.