Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Java help!

  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Java help!



    Hi
    This is my first time on this forum and i'm currently taking a programming course in second year computer engineering. I have a exam coming up soon for this course. I need some help with understanding tostring() method. What does it do? Also can someone explain to me overloading and abstract method?

    Thanks in advance. <3

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,678
    Thanks
    6
    Thanked 1,009 Times in 982 Posts
    Java and JavaScript are two different languages. Which one do you mean?

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    Java and JavaScript are two different languages. Which one do you mean?
    Java. I meant java

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,596
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    Then you need to post in the Java forum. Likely one of the moderators will move this thread.

    Are you talking about the default toString()? That is Object.toString()? Or are you talking about overriding toString() for other classes?

    As for overloading: It's simply where you have two or more methods with the same name, in the same class, that have different parameter types.
    Code:
    class zam {
        int doit( int i ) {...}   /*overloaded doit methods */
        int doit( string s ) { ... }
    };
    Distinct from overriding, where two classes have a method with the same name and parameter types and one class is derived from the other.
    Code:
    class base {
        public int doit( int i ) {...}
    };
    class child extends base {
        public int doit( int i ) { ... } /* this method overrides base.doit */
    };

    An abstract class is simply one that acts as the base class for one or more derived classes but can not itself be instantiated. (That is, if you declare
    Code:
    abstract class foo {....};
    class bar extends foo { ... };
    Then you *can* do bar b = new bar(); but you can *NOT* do foo f = new foo();
    This allows you to define the behavior of class derived from foo without needing to allow the user to create a foo object.
    Last edited by Old Pedant; 12-03-2011 at 09:42 AM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •