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, 2022 in C# by krishna
• 2,820 points
258 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, 2022 in C# by jyoti
• 1,240 points
179 views
0 votes
1 answer

Good C# interview questions book

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

answered Jun 7, 2022 in C# by rajiv
• 1,620 points
198 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, 2022 in C# by pranav
• 2,590 points
328 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, 2022 in C# by krishna
• 2,820 points
262 views
0 votes
1 answer

Convert VB.NET --> C# Projects

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

answered May 30, 2022 in C# by rajiv
• 1,620 points
343 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, 2022 in C# by rajiv
• 1,620 points
1,289 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, 2022 in C# by rajiv
• 1,620 points
218 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
1,382 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
673 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