• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inheritance Question

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Classs AA{
public void sample(String s)
{
System.out.println("String");
}
public void sample(object s)
{
System.out.println("Object");
}
}

Class BB{
public void static main(String str[])
{
AA a=new AA;
a.sample(null);
}

}


What will be the output if we compile and run please explain me.


Thnx,
Sanjay :roll:
 
Sanjay Gurav
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sanjay Gurav:
Hi,
"Sorry Its Polymorphism Question"
Classs AA{
public void sample(String s)
{
System.out.println("String");
}
public void sample(object s)
{
System.out.println("Object");
}
}

Class BB{
public void static main(String str[])
{
AA a=new AA;
a.sample(null);
}

}


What will be the output if we compile and run please explain me.


Thnx,
Sanjay :roll:

 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sanjay Gurav:
Hi,

Classs AA{
public void sample(String s)
{
System.out.println("String");
}
public void sample(object s)
{
System.out.println("Object");
}
}

Class BB{
public void static main(String str[])
{
AA a=new AA;
a.sample(null);
}

}


What will be the output if we compile and run please explain me.


Thnx,
Sanjay :roll:



Well there are a lot of typos...

Anyways also use code tags to diplay code snippets.

Anyways I am correcting your code:



Save it with BB.java and then compile it and try to run it... and also for the output check the follwoing link....


Choose the Most Specific Method

Hope it helps you out..
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic