ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
Can we have the method in drived class with the same name 
which is there in base class?
 Question Submitted By :: Samplestudy
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Can we have the method in drived class with the same name which is there in base class?
Answer
# 1
yes we can have that. in order to invoke the method of the 
same name we use base keyword before the method name. 

if the method in the base class is virtual, which is the 
case in most of the abstract classes we actually override 
the method in the derived class. 

it is therefore not a constraint in any way.
 
Is This Answer Correct ?    0 Yes 0 No
Alcheringa
 
  Re: Can we have the method in drived class with the same name which is there in base class?
Answer
# 2
yes we can have the method in drived class with the same 
name which is there in the base class, But the condition is 
both should have diffrent parameters.....that's it.
 
Is This Answer Correct ?    0 Yes 0 No
Shafi Syed
 
 
 
  Re: Can we have the method in drived class with the same name which is there in base class?
Answer
# 3
It is possible to hide the base class method with the 
derived class without using Virtual in base class and 
Override keyword in subclass.there are some condition where 
we have to redefine any method in derived class same name 
in base class now question arise how can we hide the method 
anwer is simple and logical we use the modifier NEW which 
tell the compiler that derived class method "hides the base 
class method. There are some example:
Class baseclass
{
    Public void display()
    {
        console.writeline("base method");
    }
} 
class derived : baseclass
{
    public new void display()
    {
         console.writeline("dervied mthod");
     }
} 
class test
{
     public static void main()
    {
        derived d=new derivedclass();
        d.display();
    }
}
 
Is This Answer Correct ?    1 Yes 0 No
Brijender P Rana
 
  Re: Can we have the method in drived class with the same name which is there in base class?
Answer
# 4
have a look at this link.

http://msdn2.microsoft.com/en-us/library/6fawty39
(VS.80).aspx
 
Is This Answer Correct ?    0 Yes 0 No
Ravindarjobs
[IGSA LABS]
 
  Re: Can we have the method in drived class with the same name which is there in base class?
Answer
# 5
In C#, derived classes can contain methods with the same
name as base class methods.

    *

      The base class method must be defined virtual.
    *

      If the method in the derived class is not preceded by
new or override keywords, the compiler will issue a warning
and the method will behave as if the new keyword were present.
    *

      If the method in the derived class is preceded with
the new keyword, the method is defined as being independent
of the method in the base class.
    *

      If the method in the derived class is preceded with
the override keyword, objects of the derived class will call
that method instead of the base class method.
    *

      The base class method can be called from within the
derived class using the base keyword.
    *

      The override, virtual, and new keywords can also be
applied to properties, indexers, and events.
 
Is This Answer Correct ?    1 Yes 0 No
Satya
 
  Re: Can we have the method in drived class with the same name which is there in base class?
Answer
# 6
YES its posiible to have a method with same name in the 
derived class provide with
1. base class method should be hided by removing virtual 
keyword.
2.use new keyword in derived class instead of override.
 
Is This Answer Correct ?    0 Yes 0 No
Srinivas.r
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
int i = 1; int j = 1; System.Console.WriteLine(i == j); System.Console.WriteLine(i.ToString() == j.ToString()); System.Console.WriteLine((object)i == (object)j); Give the sample code above, what is the output to the console?  3
How do you inherit from a class in C#?  1
can we access main() using objects? ssinformatics1
What?s the difference between // comments, /* */ comments and /// comments? Visual-Soft2
How can we acheive inheritance in VB.NET ? TCS2
What namespaces are necessary to create a localized application?  2
If we inherit a class do the private variables also get inherited ? TCS1
What?s the difference between the Debug class and Trace class?  2
What is the Difference between imperative and interrogative code? Wipro2
what is the difference between int and Int32? TCS4
Why is it a bad idea to throw your own exceptions?  3
Can an interface inherit an interface Synechron1
What are the ways to deploy an assembly?  1
What is the difference between readonly and constant in c# Fulcrum-Logic2
Code to run exe like mspaint,autocad etc in asp.net.  1
what is the difference between c-sharp and vb.net?What kind of security or advances we find in both languages? DataPoint1
Any exceptions are there which are not caught by any catch blocks? what are they? Honeywell5
Explain the three services model (three-tier application).  3
Are private class-level variables inherited?  3
How can you overload a method?  2
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com