Select chapter



Basics (2.papers)
Data Types (2.papers)
enums (2.papers)
OOPS (4.papers)
Arrays (1.papers)
Structs (2.papers)
Properties (2.papers)
Strings (2.papers)
Interfaces (1.papers)
Constructors (2.papers)
Ref-Out-Keywords (1.papers)
Collections (2.papers)
Generics (1.papers)
Hide

Sponsored Links


  

c# oops interview questions and answers

Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
4
Which of the below given statement is true about below given code?
    public class A
    {
        protected A() {     }
    }
    public class B : A
    {
        public  B()     {      }
    }
    public class Test
    {
        public static void Main()
        {    
             B b= new B();           
        }
    }
  1. Base class constructor should have more accessibility than the derived class constructor.
  2. B class constructor should call class A's constructor using base keyword.
  3. Access modifiers of class and constructors should be same.
  4. The code will be compiled successfully
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
Which of the following statements is true about given code?   
public class Palle 
    {
        private class A
        {
            public int y=90;
        }
        protected class B : A
        {
            public static void Main()
            {
                Palle.B b = new Palle.B();
                Console.Write(b.y);                
            }
        }       
    }
  1. Runtime Error
  2. Class A should be internal or protected
  3. Class A should be Public or protected
  4. The code will be compiled successfully and will get 90 as output
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
Which of the following statement is true about an abstract class ?
  1. Every member in an abstract class must be abstract..
  2. An abstract class must contain atleast one abstract member.
  3. An abstract class  can not contain concrete members.
  4. An abstract class may contain zero or more abstract members and zero or more concrete members.
Show Answer
Share Facebook gmail Twitter
9
Which of the following statement is true about an abstract class?
  1. We can create object to an  abstract class
  2. Implementing abstract members of an abstract class in derived class is optional
  3. We must give implementaion to the abstract base class members in the derived class
  4. Abstract class and interface both are same
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
What is a pure virtual function?
  1. A pure virtual function is a function which can not contain definition or function body.
  2. A pure virtual function is a function which is declared using pure virtual keyword.
  3. A pure virtual function is a function whose definition is present in derived class and declaration is present in base class.
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
14
What is the difference between a virtual method and an abstract method?
  1. Virtual and Abstract methods both are same
  2. A Virtual method should be overrided in derived class but in case of Abstract it is not.
  3. A Virtual method must have a body, where as an Abstract method should not have a body.
  4. Virtual and Abstract methods must be overriden in derived class
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
17
Is it possible to skip implementation of base class abstract methods in the derived class?
  1. Yes, It is possible to skip implementation of base class abstract method without declaring the derived class as abstract.
  2. Yes, It is possible to skip implementation of base class abstract method by declaring the derived class as abstract.
  3. Yes, It is possible to skip implementation of base class abstract method by declaring derived class as sealed.
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
18
Which of the following statement is true about given code?
public abstract class A
{
    public abstract int M();
    public abstract int M1();
}
public class B:A
{
    public override int M()
    {
      return 20;
    }
}
  1. Code will be compiled successfully.
  2. Compilation error, since derived class must give implementation for both the abstract methods.
  3. Runtime error while creating the object of class B.
  4. None of the above
Show Answer
Share Facebook gmail Twitter
19
Which of the following statement is true about given code?
public abstract class A
{
    protected abstract int M();
}
public class B:A
{
    public override int M()
    {
        return 10;
    }
}
  1. We can not create protected Abstract methods.
  2. Code will be compiled successfully.
  3. Overriding method must be declared as protected.
  4. Class B must be declared as abstract.
Show Answer
Share Facebook gmail Twitter
20
Which of the following statement is true about given code?
public abstract class A
{
    protected abstract virtual int M();
}
public abstract class B:A
{
    public abstract override int M();  
} 
  1. Code will be compiled successfully.
  2. Inherit the another class from B class to give implementation for M().
  3. M() method in B class should have implementation and it is can not be abstract.
  4. An abstract method can not be virtual.
Show Answer
Share Facebook gmail Twitter
Read more papers :