Problem compiling Abstract class

Hi
I have writting an abstract class Sort.java and another class BubbleSort.java. I am having problems compiling BubbleSort.java class.
The following is the error message
BubbleSort.java:8: missing method body, or declare abstract
     public int doSorting(int[] array);
^
BubbleSort.java:11: return outside method
          return num;
^
The following is the code
public abstract class Sort
public abstract int doSorting(int[] array);
}// End of class
public class BubbleSort extends Sort
private int num = 2;
public int doSorting(int[] array);
num = num + 2;
return num;
} // end of class

Remove the semi-colon.
public int doSorting(int[] array); // <------- there

Similar Messages

  • Problems implementing abstract classes

    hello.
    this is james mcfadden. I am developing a multiplayer BlackJack card game in Java. the game consists of three programs: BlackJack.java, BlackJackServer.java and BlackJackClient.java (three 3 programs are shown below). i don't know how to implement abstract classes. i am trying to get the BlackJack.java program working with the BlackJackServer.java program. there should be "extends BlackJackServer" somewhere in the BlackJack.java program, but i don't know where.
    import javax.swing.*;
    public class BlackJack extends JPanel{
       public BlackJack(){
          //FlowLayout is default layout manager for a JPanel
          add(new JButton("Hit"));
          add(new JButton("Stay"));
          add(new JButton("New Game"));
       public static void main(String[] args){
          JFrame frame=new JFrame("BlackJack");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(500,500);
          frame.setLocation(200,200);
          BlackJack bj=new BlackJack();
          frame.setContentPane(bj);
          frame.setVisible(true);
    import java.io.*;//Provides for system input and output through data streams, serialization and the file system
    import java.net.*;//Provides the classes for implementing networking applications
    import java.util.*;//Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes
    import java.awt.*;//Contains all of the classes for creating user interfaces and for painting graphics and images
    import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
    public class BlackJackServer extends JFrame{
       private JTextArea jta=new JTextArea();//a text area for displaying text
       public static void main(String[] args){  
              new BlackJackServer();//invokes the constructor BlackJackServer()
       }//end main
       public BlackJackServer(){
          setLayout(new BorderLayout());//places the text area on the frame
          add(new JScrollPane(jta),BorderLayout.CENTER);//lays out a text area, arranging and resizing its components to fit in the centre region;and provides a scrollable view of a lightweight component
          setTitle("BlackJack Server");//Sets the title for this frame to the specified string
          setSize(500,300);//Resizes this component so that it has a width and a height
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//Sets the operation that will happen by default when the user closes this frame
          setVisible(true);//shows the frame
          try{
             ServerSocket serverSocket=new ServerSocket(8000);//creates a server socket
             jta.append("Server started at "+new Date()+'\n');//displays the current date in the text area
             Socket socket=serverSocket.accept();//listens for a connection request
             DataInputStream inputFromClient=new DataInputStream(socket.getInputStream());//creates a data input stream
             DataOutputStream outputToClient=new DataOutputStream(socket.getOutputStream());//creates a data output stream
             while(true){
                float bet=inputFromClient.readFloat();//receives bet from the client
                float doublebet=bet+bet;//computes double the bet
                outputToClient.writeFloat(doublebet);//sends double the bet back to the client
                jta.append("Bet received from client: "+bet+'\n');//displays the bet in the text area
                jta.append("Double the bet found: "+doublebet+'\n');//displays double the bet in the text area
             }//end while
          }//end try
          catch(IOException ex){
             System.err.println(ex);//displays an error message
          }//end catch
       }//end constructor
    }//end class BlackJackServer
    import java.io.*;//Provides for system input and output through data streams, serialization and the file system
    import java.net.*;//Provides the classes for implementing networking applications
    import java.awt.*;//Contains all of the classes for creating user interfaces and for painting graphics and images
    import java.awt.event.*;//Provides interfaces and classes for dealing with different types of events fired by AWT components
    import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
    public class BlackJackClient extends JFrame{
       private JTextField jtf=new JTextField();//a text field for receiving text
       private JTextArea jta=new JTextArea();//a text area for displaying text
       private DataOutputStream toServer;//output stream
       private DataInputStream fromServer;//input stream
       public static void main(String[] args){
          new BlackJackClient();//invokes the constructor BlackJackClient()
       public BlackJackClient(){
          JPanel p=new JPanel();//holds the label and text field
          p.setLayout(new BorderLayout());//sets the layout of the content pane of this component by default
          p.add(new JLabel("Enter bet"),BorderLayout.WEST);//displays the bet and lays out a JLabel, arranging and resizing its components to fit in the western region
          p.add(jtf,BorderLayout.CENTER);//lays out the text field, arranging and resizing its components to fit in the centre region
          jtf.setHorizontalAlignment(JTextField.RIGHT);//Sets the horizontal alignment of the text to the right
          setLayout(new BorderLayout());//places the text area on the frame
          add(p,BorderLayout.NORTH);//lays out the text field, arranging and resizing its components to fit in the northern region
          add(new JScrollPane(jta),BorderLayout.CENTER);//lays out a text area, arranging and resizing its components to fit in the centre region;and provides a scrollable view of a lightweight component
          jtf.addActionListener(new ButtonListener());//invokes the ButtonListener class
          setTitle("BlackJack Client");//Sets the title for this frame to the specified string
          setSize(500,300);//Resizes this component so that it has a width and a height
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//Sets the operation that will happen by default when the user closes this frame
          setVisible(true);//shows the frame
          try{
             Socket socket=new Socket("localhost",8000);//creates a socket to connect to the server
             fromServer=new DataInputStream(socket.getInputStream());//creates an input stream to receive data from the server
             toServer=new DataOutputStream(socket.getOutputStream());//creates an output stream to send data to the server
          }//end try
          catch(IOException ex){
             jta.append(ex.toString()+'\n');//displays an error message
          }//end catch
       private class ButtonListener implements ActionListener{
          public void actionPerformed(ActionEvent e){
             try{
                float bet=Float.parseFloat(jtf.getText().trim());//gets the bet from the text field
                toServer.writeFloat(bet);//Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream
                toServer.flush();//Flushes this output stream and forces any buffered output bytes to be written out
                float doublebet=fromServer.readFloat();//gets double the bet from the server
                jta.append("Bet is "+bet+"\n");//displays the bet in the text area
                jta.append("Double the bet received from the server is "+doublebet+'\n');//displays double the bet in the text area
             }//end try
             catch(IOException ex){
                System.err.println(ex);//displays an error message
             }//end catch
          }//end method
       }//end class
    }//end class BlackJackClient

    there should be "extends BlackJackServer" somewhere in the BlackJack.java programI very much doubt that.
    It's possible you might need to create a BlackJackServer object or something like that. But I don't see the point in subclassing it.

  • Problems with abstract classes

    I'm reading Java Wireless Blueprints and i'm confused with the functionality of abstract classes, especially in the next section:
    public byte[] getPoster() throws ApplicationException {
    if (poster == null) {
    try {
    poster =
    ModelObjectLoader.getInstance().getMoviePoster(primaryKey);
    } catch (ModelException me) {
    throw new ApplicationException();
    return poster;
    This class invoque to the ModelObjectLoader class that is abstract and after invoque getInstance().getMoviePoster(primaryKey); method. The source code of the class is:
    public abstract class ModelObjectLoader {
    private static ModelObjectLoader instance = null;
    protected ModelObjectLoader() {
    instance = this;
    return;
    public static ModelObjectLoader getInstance() {
    return instance;
    public abstract TheaterSchedule getTheaterSchedule(Theater theater)
    throws ModelException, ApplicationException;
    public abstract Movie getMovie(String movieKey)
    throws ModelException, ApplicationException;
    public abstract Movie getMovie(Movie movie)
    throws ModelException, ApplicationException;
    public abstract byte[] getMoviePoster(String movieKey)
    throws ModelException, ApplicationException;
    public abstract int[][] getMovieShowTimes(String theaterKey, String movieKey)
    throws ModelException, ApplicationException;
    public abstract SeatingPlan getSeatingPlan(String theaterKey,
    String movieKey,
    int[] showTime) throws ModelException,
    ApplicationException;
    I don�t find where is the implementation of the getMoviePoster(primaryKey) method.
    Can you help me to understand.
    Thanks

    public abstract byte[] getMoviePoster(String movieKey)It's an abstract method, which means that any concrete class that extends ModelObjectLoader must implement the method. If you really need to know (you might not), then call getInstance() and output the result of getClass().getName() on that object. That will tell you its type, and then you can go look at the source.

  • Object oriented design problem concerning abstract classes and interfaces

    I have an abstract class (class A) that takes care of database connections. It cannot be made into an interface as other classes extend it and all these other classes require the functionality in the methods it has (i.e. I cannot make all the methods abstract and then make this class an interface).
    I have a class that contains data (Customer class) that I will create from the data I extract from the database. This class will also be created by the User and submitted to the database portion of the program. The Customer class has functionality in its methods which is required by the rest of the program (i.e. I cannot make all the methods abstract and then make this class an interface).
    I have a factory class (CustomerFactory) that extends the Customer class. This has been created to restrict access to the creation and manipulation of Customers.
    I have a class (DatabaseQuery) that extends class A. But now that I have retrieved all of the information that comprises a Customer from the database, I cannot construct a Customer without making reference to UserFactory. But UserFactory is a class that I don't want the database portion of the program to know about.
    What I would like to do is have my DatabaseQuery class extend both Customer class and A class. But they are both classes and Java won't allow that.
    I can't make either of the two classes that I want to make parents of DatabaseQuery into interfaces... so what can I do other than just keep a reference to UserFactory in my DatabaseQuery class?
    Thanks,
    Tim

    >
    What I would like to do is have my DatabaseQuery class
    extend both Customer class and A class. But they are
    both classes and Java won't allow that.
    I can't make either of the two classes that I want to
    make parents of DatabaseQuery into interfaces... so
    what can I do other than just keep a reference to
    UserFactory in my DatabaseQuery class?Just a guess...
    The description sounds a little vague but it sounds like the correct solution would be to refactor everything. The first clue is when I see "database connection" as an "abstract class". The only hierarchy that a database connection might exist in is in a connection pool and even that is probably shaky. It should never be part of data records, which is what your description sounds like.
    That probably isn't what you want to hear.
    The other solution, which is why refactoring is better (and which also makes it apparent why the original design is wrong) is to create an entire other hierarchy that mirrors your current data hierarchy and wraps it. So you now have "Customer", you will now have "Customer" and "DBCustomer". And all the code that currently uses "Customer" will have to start using DBCustomer. Actually it is easier than that since you can simply make the new class be "Customer" and rename the old class to "DBCustomer". Naturally that means the new class will have to have all of the functionality of the old class. Fortunately you can use the old class to do that. (But I would guess that isn't going to be easy.)

  • Problem Compiling Inner Class

    Can anyone tell me why the following won't compile?
    Error : variable f might not have been initialized return f.getName();
         public void createNodes(File root, DefaultMutableTreeNode node)
              File [] files = root.listFiles();
              for(int counter = 0; counter < files.length; ++ counter)
                   final File f = new File(files[counter].getPath())
                        public String toString()
                             return f.getName(); // Compiler error
                             //return ("ABC"); OKAY
                   if(f.isDirectory())
                        DefaultMutableTreeNode dirNode = new DefaultMutableTreeNode(f.getName());
                        node.add(dirNode);
                        dirNode.setAllowsChildren(true); // HANDLE EMPTY DIRECTORIES
                        createNodes(f, dirNode);
                   else
                        DefaultMutableTreeNode fileNode = new DefaultMutableTreeNode(f);
                        node.add(fileNode);
                        fileNode.setAllowsChildren(false);
         }

    I had coded the thing like:
        for (int i = 0; i < files.length; i++) {
          final File f = new File(files[1].getPath()) {   // Yes that's a one in there
            public String toString() {
              return getName();
          System.out.println(f);
        }... Then passed into it a directory that contained a class named similar to an anonomous class name, and it just happened to be the 2nd file listed (files[1] that is) ... and therefore I got a whole bunch of that class name.class down the page instead of the entire contents of the directory ... and, oh well, threw me off ... like I said I think I need some sleep.
    ~Bill

  • Problem compiling - Missing classes???

    I am trying to recompile my java classes using javac.exe and I get about 38 errors all saying "cannot resolve symbol"...I used to get more, but I figured it couldn't find some of the classes. I looked in the .java file and found the list of imports and found most of them, but I can not find the following that are being called:
    import java.applet.Applet;
    import java.applet.AppletContext;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    From what i have read, they should come with the Java 1.31 development kit, but I do not find them anywhere on my machine. I am new to Java and was asked to make some changes, so any help on this would really be appreciated.
    Thanks.

    These are all in the Java system jar. Do you have JRE or JVM installed?
    You could try reinstalling Java JVM.
    Regards,
    Tim

  • Inheritance problem with parent class calling child class

    I have a problem with inheritance with a parent class calling a child class method. Below is the example pseudocode code and my problem:
    public abstract class A {
        protected void function1 ( ) { }
        protected void function2 () {
             //calls function1();
             function1();
    public abstract class B extends A {
        protected void function1 ()  {
             // do stuff
    public class C extends B {
        protected void function1 ()  {
            // do stuff
            super.function1 ();
    }I have an object instance of class C created and its function2() is invoked.
    My problem is, while in function2(), which belongs to abstract class A and the method call to function 1() is called, the call invokes the function1() of class B. Shouldn't the call invoke function 1() of class C instead? And then function1() of class B will be called after due to the super.function1(). It's not behaving like I thought it would.
    Edited by: crono77 on Jan 10, 2008 8:13 PM

    Nevermind, i found my error :)

  • Abstract Class Compiling Problem

    This is my first time using the code tags, I apologize if I didn't do it right.
    I can't seem to get the subclass to compile properly. I have defined an abstract class TemplateLoginCommand that encapsulates all of the login functionality. I have defined two abstract classes success and failure that should hold the code to forward the app to the right page on success, or handle any errors on login. I keep getting the following error message when I try to compile KlLoginCommand:
    I am removing the package info so my boss doesn't flip
    ../command/KlLoginCommand.java [17:1] ../command.KlLoginCommand should be declared abstract; it does not define failure() in ../.command.TemplateLoginCommand
    public class KlLoginCommand extends TemplateLoginCommand
    ^
    1 error
    Can anyone see what I am doing wrong here. I don't have a lot of experience with abstract classess/methods. Thanks
    public abstract class TemplateLoginCommand extends PageVerificationCommand implements Constants
        // Required Form Fields
        public static final String[] REQUIRED_FIELDS = {USERNAME, PASSWORD};
        // Abstract Methods Must Be Subclasses
        abstract void success(UserEntity entity);
        abstract void failure();
        /** Creates new TemplateLoginCommand */
        public TemplateLoginCommand()
            super();
        public TemplateLoginCommand(String childDirectory)
            super(childDirectory);
        public void destroy(Map map) throws Exception
            super.destroy(map);
            // Validate
            if (verifyFields(REQUIRED_FIELDS, map))
                // Attempt login
                try
                    String username = (String) map.get(USERNAME);
                    String password = (String) map.get(PASSWORD);
                    UserEntity user = UserEntity.login(username, password);
                    // Forward to rolemenu
                    success(user);
                    return;
                catch( SQLException sqle )
                    failure();
                    return;
            else
                failure();
                return;
    public final class KlLoginCommand extends TemplateLoginCommand
        /** Creates a new instance of KlLoginCommand */
        public KlLoginCommand()
        protected void failure()
        protected void success(UserEntity entity)
    }

    Hi,
    Try making the methods
    // Abstract Methods Must Be Subclasses
    abstract void success(UserEntity entity);
    abstract void failure();
    protected.
    Roger

  • Abstract class hierarchy - compilation error

    I coded an abstract class and couple of concrete classes. When I am compiling the concrete classes, I see the error message: cannot find symbol abstract class. For diagnosing I coded very simple programs AbstractClass1.java and ConcreteClass.java. Again I am facing the same compilation error. Code is given below:
    abstract class AbstractClass1 {
    protected AbstractClass1() {
    System.out.println("AbstractClass1 constructor called");
    public abstract void distinct_method();
    public void common_method() {
    System.out.println("common method called");
    distinct_method();
    class ConcreteClass extends AbstractClass1 {
    public void distinct_method() {
    System.out.println("distinct_method called");
    I can't figure out what's causing the compilation error.
    Edited by: ague on Nov 9, 2008 5:52 PM

    Yes. AbstractClass1 is defined in AbstractClass1.java. I know it is compiling fine for others. I am unable to figure out the problem at my end because the problem was first encountered with a different (and bigger) program. I then started using new simpler classes to zero in on the problem area. I copied the code from java forum so I know it can't be a problem with code. You and one more person confirmed it. In my first post I was focusing on abstract class because the problem started when I began coding a hierarchy with an abstract class at the top. Other programs are working fine. Thanks anyway.

  • Problems with extension of generic abstract class

    Hello,
    I'm having some problems with the extension of a generic abstract class. The compiler tells me I have not implemented an abstract method but I think I have. I have defined the following interface/class hierarchy:
    public interface Mutator<T extends Individual<S>, S> {
         public void apply( T<S> ind );
    public abstract class AbstractMutator<T extends Individual<S>, S> implements Mutator<T, S> {
         public abstract void apply( T<S> ind );
    }Now I implement AbstractMutator as such:
    public class BinaryMutator extends AbstractMutator<StringIndividual<Integer>, Integer> {
         public void apply( StringIndividual<Integer> ind ) { ... }
    }The compiler says:
    BinaryMutator.java:3: ga.BinaryMutator is not abstract and does not override abstract method apply(ga.Individual<java.lang.Integer>) in ga.AbstractMutator
    Why does it say the signature of the abstract method is apply(Individual<Integer>) if I have typed the superclass as StringIndividual<Integer>?
    Thanks.

    Yes, but the abstract method takes an arg of type <T extends Individual>. So it takes an Individual or a subclass thereof, depending on how I parameterise the class, right? StringIndividual is a subclass of Individual. So if I specify T to be StringIndividual, doesn't the method then take an arg of type StringIndividual?

  • Problem heriting fro abstract class

    Hi, i try to use abstract classes for the first time, i write this code:
    public abstract class ClassA{
    abstract void getValue();
    public lass ClassB extends ClassA{
    void getValue(){
    }But when i compile i get this message: ClassB must be abstract, it does not implements ClassA. What is wrong please?

    Should not a method called getValue() return a value?
    The following compiles
    // In a file called ClassA.java
    public abstract class ClassA {
        public abstract int getValue();
    // In a file called ClassB.java
    public class ClassB extends ClassA {
        private int value;
        public void getValue() {
            return value;
    }If your abstract class has only abstract methods and you don't need the method to be package-private scope. You can just use an interface.
    // In a file called InterfaceA.java
    public interface InterfaceA {
        public int getValue();
    // In a file called ClassB.java
    public class ClassB implements InterfaceA {
        private int value;
        public void getValue() {
            return value;

  • Problems compiling class within package

    Hi, I have a package called jicmp, and within this package i have 3 classes, namely timeoutexception, icmppacket and jicmp. the first two compile fine, but when i try to compile jicmp, it complains. in jicmp i have the following methods:
    public void send(icmppacket packet)
    public icmppacket read()
    and it doesnt like to use timeoutexception either. why is this? they are in the same package, and all have the package name at the top, and all are in the same directory..
    Any help would be gratefully received
    Thanks
    Vanessa

    Hi,
    Did you creat a folder with same name as your package name.
    If not, do it first. then compile your class with the following command.
    exmample:
    C://javac foldername.filename.java
    to run:
    C://java foldername.filename
    it will work.

  • Implementing Comparable in an abstract class

    Hi all,
    I am making my first sortie with abstract classes. I have had a good look around, but would still appreciate some advice with the following problem.
    In my application I have several classes that have many things in common. I have concluded therefore, that if I create and then inherit from an abstract super class, I can reduce and improve my code. I created this abstract class:
    public abstract class YAbstractObject implements Comparable {
        public YAbstractObject(int projectId, YObject object, String objectName) {
            this.projectId = projectId; // Always the same parameters
            this.object = object;
            this.objectName = objectName;
        // This is abstract as it must always be present for sub classes but differant processing will take place
        public abstract void resolveObject();
        // These three methods will always be the same for all sub classes
        public String getName() {
            return objectName;
        public YObject getObject() {
            return object;
        public boolean isValid() {
            return isValid;
    // Overridden and always the same for all sub classes
        public String toString() {
            return objectName;
        // implemented abstract method
        public int compareTo(Object thatObject) {
            // Issue here! I would like something as follows:
            //  return this.getName().compareToIgnoreCase(thatObject.getName());
    // Variable decleration
        private int projectId;
        private YObject object;
        private String objectName;
        private boolean isValid;As I have commented in the compareTo() method, I would like it to be able to use the getName() method for comparison objects and compare them. But it does not like this, as it does not know that "thatObject" is of the same class as this object - I hope that made sense.
    in essence, I want to inherit this method for different classes and have it work with each.
    Is there a way to do this? Generics?
    Any observations, greatly appreciated,
    Steve

    You can use also generics (if applicable: java -version >= 1.5).
    public abstract class Test implements Comparable<Test> {
         String name;
         public Test(String name) {
              this.name = name;
         public String getName() {
              return name;
         public int compareTo(Test obj) {
              return this.getName().compareTo(obj.getName());
    public class Other extends Test {
         public Other(String name) {
              super(name);
    public class Tester extends Test {
         public Tester(String name) {
              super(name);
         public static void main(String[] args) {
              Test t = new Tester("t");
              Test a = new Tester("a");
              Test o = new Other("t");
              System.out.println(t.compareTo(a));
              System.out.println(t.compareTo(new Object())); //compile error
              System.out.println(t.compareTo(o));
    }Without the compile error line it will give the following result:
    19
    0

  • Abstract class confusion

    I am writing a J2ME application, and I want to write a Record management system (RMS) that I can use in other J2ME programs. I have a Record class that RMS classes need to know about. The idea is that the Record class is abstract, and the implementation is defined by a subclass - depending on what the application needs to store. Any Record must provide the following:
    1) A constructor which takes a single byte[] parameter, which is the data read in from the RecordStore by the RMS. The implementation depends on what information is stored in this type of Record - it might be a String, series of ints, etc...
    2) A method getStorageFormat() which returns a btye[] representing the data to be stored in the RecordStore. Again, this is dependent on the application.
    I think that I have to use an abstract class here, so I have written an abstract class called Record - here's what it looks like:
    public abstract class Record {
         public Record(byte[] bytes) { }; //Should this be an empty constructor?
         public abstract byte[] getStorageFormat();
    }My problem is that I can't define a subclass of Record that works! Here's an example:
    public class MyRecord extends Record {
           String data1, data2, data3; //Some data that is stored in this record
           public MyRecord(byte[] bytes) {
                  String data = new String(bytes);
                  // do some processing to extract the data...
           public byte[] getStorageFormat() {
                  String sep = ","; //A seperator
                  String tmp = data1 + sep + data2 + sep + data3; //put all the data together with
                  return tmp.getBytes();
    }}I get an error in Eclipse with the MyRecord constructor that says:" The implicit super constructor Record() is undefined. Must explicity invoke another constructor". I tried super() but I get the same error. Can anyone please tell me what I am doing wrong? It seems to me that I am misunderstanding something about how abstract classes work.

    Because you defined a ctor that takes args, the implicit one that takes no args--super()--is no longer implicitly supplied. You have to either put a no-arg ctor into the parent class, or call the one that you already have.
    public Record(byte[] bytes) { }; //Should this be an empty constructor?
    public abstract byte[] getStorageFormat();
    }No. You don't want a ctor that takes args and does nothing. If you're taking that arg, then you should use it to initialize the state of the object.
    Here are the rules for constructors--"ctors" because I'm lazy. Also, because I'm lazy, "super(...)" and "this(...)" mean any super or this call, regardless of how many args it takes, including those that take no args.
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a
    public MyClass() {...}
    if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor
    super(...)
    or a call to another ctor of this class
    this(...)
    2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor
    super()
    as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • Extend abstract class & implement interface, different return type methods

    abstract class X
    public abstract String method();
    interface Y
    public void method();
    class Z extends X implements Y
      // Compiler error, If I don't implement both methods
      // If I implement only one method, compiler error is thrown for not
      // implementing another method
      // If I implement both the methods,duplicate method error is thrown by 
      //compiler
    The same problem can occur if both methods throw different checked exceptions,or if access modifiers are different..etc
    I'm preparing for SCJP, So just had this weired thought. Please let me know
    if there is a way to solve this.

    Nothing you can do about it except for changing the design.
    Kaj

Maybe you are looking for

  • CD Burn Fail. Error 4280

    The attempt to burn a disk failed. An unknown error occured. 4280 How do I fix this? What does it mean? Diagnostics is able to read and report the drive and error. (Mashita UJ840D)

  • Converting byte[] to short, long, etc.

    I need to packetize the data with my own header embedded in the data. The header field is composed of data types: short, byte, and long. Since the header will be transported over the network using UDP socket, it will have to be converted to type byte

  • Slow Performance Oracle 9i

    Hello There; Our company OLAP database is facing performance issues where 1 simple query could take it more than to 20 mins to return result. I am newbie to Oracle DB, i was told to look at the explain plan and yes , the plan looks alright where it u

  • Port Issues on Ichat

    I have had problems several times I have had to log on to ichat but it displays the message "the connection could not be completed because it has timed out.try again? Now, I have tried to switch the port from 5190 to 443 but which lets me log in to m

  • Effective way to clean the dust out of your Macbook Pro?

    Lately the fan on my Macbook Pro has been running a lot much more often & it has been making a lot more noise; mainly because it is clogged with a lot of dust. Is there an effective way to cleaning it out? If so, how? Be detailed as possible.