Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java: interfaces and abstract classes

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java: interfaces and abstract classes

    Hello everybody!
    I use the actiWATE library for one project. This is a code

    file Main.java
    import bro.bro;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
     
    public class Main
    {
    public static void main(String[] args) throws UnsupportedEncodingException, IOException
    {
    bro doBro= new bro();
    }
    }
    file bro.java
    package bro;
     
    import com.actimind.actiwate.http.HttpResponse;
    import com.actimind.actiwate.testing.ActiwateTestCase;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
     
    public class bro extends ActiwateTestCase {
    public bro() throws UnsupportedEncodingException, IOException{
           disableJavaScript(true);
           goTo( "http://google.com" );
     
    }
    }
    And now I want to get all headers. In this library is a method getAllHeaders()

    file bro.java
    package bro;
     
    import com.actimind.actiwate.http.HttpResponse;
    import com.actimind.actiwate.testing.ActiwateTestCase;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
     
    public class bro extends ActiwateTestCase {
    public bro() throws UnsupportedEncodingException, IOException{
           disableJavaScript(true);
           goTo( "http://google.com" );
     
    }
    public class WOW implements HttpResponse 
    {
     
    }
     
    }
    but NetBeans IDE 6.8 required implementing all abstract methods. It's great but the next step is the overriding all these methods but I don't want it. I want use method getAllHeaders() without any overriding because it returns all header in one string.

    Ok. In order to don't overriding method I do it like an abstract class WOW with implements HttpResponse

     package bro;
    import com.actimind.actiwate.http.HttpResponse;
    import com.actimind.actiwate.testing.ActiwateTestCase;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
     
    public class bro extends ActiwateTestCase {
    public bro() throws UnsupportedEncodingException, IOException{
           disableJavaScript(true);
           goTo( "http://google.com" );
     
    }
    public abstract class WOW implements HttpResponse 
    {
     
    }
     
    }
    The creation of objects from abstract classes is impossible and we need to create a class that extends abstract class WOW like this
    package bro;
     
    import com.actimind.actiwate.http.HttpResponse;
    import com.actimind.actiwate.testing.ActiwateTestCase;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
     
    public class bro extends ActiwateTestCase {
    public bro() throws UnsupportedEncodingException, IOException{
           disableJavaScript(true);
           goTo( "http://google.com" );
     
    }
    public abstract class WOW implements HttpResponse
    {
     
    }
     
    public class WOW2 extends WOW
    {
     
    }
     
    }
    But in this case IDE requires the implementation of all abstract methods with them overriding again! How can I avoid it and use this method? Thanks for all answers!
    Last edited by helloworld922; May 6th, 2010 at 10:24 AM.


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Java: interfaces and abstract classes

    I know it's probably history by now, but HttpResponse is an interface. If you read the framework docs, you don't need to implement it, it is returned by the framework for you to use. See Accessing Non-HTML Content.

Similar Threads

  1. Importance of interfaces
    By jyothishey in forum Object Oriented Programming
    Replies: 9
    Last Post: March 12th, 2010, 07:11 AM
  2. Implementing Multiple Interfaces with Generics
    By darkestfright in forum Collections and Generics
    Replies: 5
    Last Post: February 10th, 2010, 08:44 PM
  3. A Question Regarding Abstract Classes & Packages
    By Kerubu in forum Object Oriented Programming
    Replies: 3
    Last Post: December 21st, 2009, 01:27 PM
  4. [SOLVED] Error "TitleChanger is abstract; cannot be instantiated"
    By Uzual in forum AWT / Java Swing
    Replies: 2
    Last Post: May 26th, 2009, 11:23 AM
  5. Java program with abstract class along with two subclasses
    By crazydeo in forum Collections and Generics
    Replies: 2
    Last Post: June 10th, 2008, 11:45 AM