C Potential Interview Question Too hard

0 votes

Determine which Foo method will be invoked without running the code:

class A
{
   public void Foo( int n )
   {
      Console.WriteLine( "A::Foo" );
   }
}

class B : A
{
   /* note that A::Foo and B::Foo are not related at all */
   public void Foo( double n )
   {
      Console.WriteLine( "B::Foo" );
   }
}

static void Main( string[] args )
{
   B b = new B();
   /* which Foo is chosen? */
   b.Foo( 5 );
}

Which technique? Then why? Run the code without trying to trick it.

I came across this problem online, and I think I'll use it as a question in an interview because I enjoy it. Link: http://netpl.blogspot.com/2008/06/c-puzzle-no8-beginner.html

Sep 27 in C# by krishna
• 2,820 points
28 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C#

0 votes
0 answers

ReverseString, a C# interview-question

I was asked for my 'input' on ...READ MORE

Jun 11 in C# by jyoti
• 1,240 points
34 views
0 votes
1 answer

Good C# interview questions book

If you're simply familiar with the foundations ...READ MORE

answered Jun 7 in C# by rajiv
• 1,620 points
44 views
0 votes
1 answer

Are these interview questions too challenging for beginners?

As a new employee, I would expect ...READ MORE

answered Jun 11 in C# by pranav
• 2,580 points
62 views
0 votes
1 answer

Simple VB or C# questions for an interview

The difficulty with asking language-specific questions for ...READ MORE

answered Jun 13 in C# by krishna
• 2,820 points
52 views
0 votes
1 answer

Convert VB.NET --> C# Projects

You may decompile whole Assemblies into Visual ...READ MORE

answered May 30 in C# by rajiv
• 1,620 points
47 views
0 votes
1 answer

What is the best C# to VB.net converter

Telerik has a solid SharpDevelop-based converter that ...READ MORE

answered May 30 in C# by rajiv
• 1,620 points
511 views
0 votes
1 answer

C# Potential Interview Question…Too hard?

This isn't a question I'd ask in ...READ MORE

answered Jun 7 in C# by rajiv
• 1,620 points
51 views
0 votes
1 answer
0 votes
2 answers

Is there a .NET equivalent to Apache Hadoop?

Hadoop is a Java-based platform. So, to ...READ MORE

answered Jul 16, 2020 in Big Data Hadoop by Suhana
• 340 points
776 views
0 votes
1 answer

Validate String against USPS State Abbreviations

Try something like this: private static String states ...READ MORE

answered Sep 20, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
278 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP