Results 1 to 7 of 7
  1. #1
    vini11 is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Method Overriding

    Write A Program that illustrate method overriding. Class Bond is extended by ConvertibleBond. Each of these classes defines a display() method that outputs Bonds and ConvertibleBonds respectively. Declare an array to hold 6 Bond objects. Initialize the elements of an array with mix of Bond and CovertibleBond objects. Execute a program loop to invoke the display() method of each object.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Method Overriding

    That's nice for you.
    Do come back when you have a problem.

  3. #3
    vini11 is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Method Overriding

    please help me to complete my assignment. m confused.....

    class Bond
    {
    public void display()
    {
    System.out.println("BOND");
    }
    }
    class ConvertibleBond extends Bond
    {
    public void display()
    {
    System.out.println("Convertible Bond");
    }
    }
    class CvB
    {
    public static void main()
    {
    Bond CB = new ConvertibleBond();
    Bond B=new Bond();
    Bond b[] = new Bond[5];
    b[0]=CB;
    b[1]=B;
    b[2]=CB;
    b[3]=B;
    b[4]=CB;
    b[5]=B;
    for(int i=0;i<5;i++)
    {
    b[i].display();
    }
    }
    }

    this is my code m getin 1 error... :(

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,023
    Blog Entries
    7
    Rep Power
    20

    Default Re: Method Overriding

    Quote Originally Posted by vini11 View Post
    this is my code m getin 1 error... :(
    And now you want us to guess what that one single error is and where it is? Goody, what can we win?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    vini11 is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Method Overriding

    java.lang.NoSuchMethodError...
    i did'nt tell anybody to guess error..
    i jst wanted to know how to solve that programs.

  6. #6
    vini11 is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Method Overriding

    got ans for that program... :) :D

    class Bond
    {
    public void display()
    {
    System.out.println("BOND");
    }
    }
    class ConvertibleBond extends Bond
    {
    public void display()
    {
    System.out.println("Convertible Bond");
    }
    }
    class CvB
    {
    public static void main(String args[])
    {
    Bond CB = new ConvertibleBond();
    Bond B=new Bond();
    Bond [ ]b = new Bond[6];
    b[0]=CB;
    b[1]=B;
    b[2]=CB;
    b[3]=B;
    b[4]=CB;
    b[5]=B;
    for(int i=0;i<=5;i++)
    {
    b[i].display();
    }
    }
    }

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,609
    Rep Power
    23

    Default Re: Method Overriding

    We still do not know where your problem is.
    Please post the full text of the error message. Your edited version left off important information

Similar Threads

  1. Overriding toString method
    By son012189 in forum New To Java
    Replies: 4
    Last Post: 11-20-2011, 05:04 AM
  2. What is use of method overloading and overriding
    By srinivasmallabathula in forum New To Java
    Replies: 3
    Last Post: 04-06-2011, 07:07 AM
  3. overriding toString method
    By matin1234 in forum New To Java
    Replies: 3
    Last Post: 06-01-2010, 04:35 AM
  4. Method Overriding - Seriously confused :-(
    By fullmetaljacket in forum New To Java
    Replies: 4
    Last Post: 05-26-2009, 04:18 PM
  5. is overriding static method possible
    By raghu in forum Advanced Java
    Replies: 1
    Last Post: 01-22-2008, 12:38 AM

Posting Permissions

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