Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2010
    Posts
    25
    Rep Power
    0

    Thumbs down sample program for polymorphism

    class A
    {
    public void display(int num)
    {
    system.out.println(num);
    }
    public void display(long num)
    {
    system.out.println(num);
    }
    public static void main(String args[])
    {
    A a=new A[];
    a.display(10);
    }
    }
    which method invoke first?
    please provide correct answer.here long also part of integer type.difference is only memory allocations.

  2. #2
    mr.ab18 is offline Member
    Join Date
    Aug 2010
    Posts
    4
    Rep Power
    0

    Default

    if you write 10 then it will be considered as int. If you write 10L, it will be considered as long. Your code has error too. it should be A();

Similar Threads

  1. Polymorphism Help
    By AWPtic in forum New To Java
    Replies: 5
    Last Post: 04-06-2009, 04:13 PM
  2. question about polymorphism
    By becky in forum New To Java
    Replies: 4
    Last Post: 02-11-2009, 10:59 PM
  3. what is polymorphism
    By Nari in forum New To Java
    Replies: 5
    Last Post: 04-04-2008, 03:14 AM
  4. Replies: 1
    Last Post: 02-16-2008, 03:33 AM
  5. what's polymorphism?
    By christina in forum New To Java
    Replies: 2
    Last Post: 08-05-2007, 10:29 PM

Tags for this Thread

Posting Permissions

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