C # - Polymorphism Question and Answer

C # - Polymorphism Question and Answer
1. Which of the following unary operators can be overloaded?
1  true
   2 false
   3  +
   4 new
    is
  • 1, 2, 3
  • 3, 4, 5
  • 3 only
  • 5 only
Show Answer
2. A derived class can stop virtual inheritance by declaring an override as
  • inherits
  • extends
  • inheritable
  • not inheritable
Show Answer
3. Which of the following keyword is used to change the data and behavior of a base class by replacing a member of a base class with a new derived member?
  • new
  • base
  • overloads
  • override
Show Answer
4. Which of the following statements is correct?
  • When used as a modifier, the new keyword explicitly hides a member inherited from a base class.
  • Operator overloading works in different ways for structures and classes.
  • It is not necessary that all operator overloads are static methods of the class.
  • The cast operator can be overloaded.
Show Answer
5. Which of the following keyword is used to overload user-defined types by defining static member functions?
  • op
  • opoverload
  • operator
  • operatoroverload
Show Answer
6. Which of the following statements is correct?
  • Static methods can be a virtual method.
  • Abstract methods can be a virtual method.
  • It is necessary to override a virtual method.
  • When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overriden.
Show Answer
7. Which of the following statements are correct?

    All operators in C#.NET can be overloaded.
    We can use the new modifier to modify a nested type if the nested type is hiding another type.
    In case of operator overloading all parameters must be of the different type than the class or struct that declares the operator.
    Method overloading is used to create several methods with the same name that performs similar tasks on similar data types.
    Operator overloading permits the use of symbols to represent computations for a type.
  • 1, 3
  • 2, 4
  • 2, 5
  • 3, 4
Show Answer
8. Which of the following statement is correct about the C#.NET code snippet given below?

public class Sample
{
    public int x;
    public virtual void fun()
    { }
}
public class DerivedSample : Sample
{
    new public void fun()
    { }
}

  • DerivedSample class hides the fun() method of base class.
  • The DerivedSample class version of fun() method gets called using Sample class reference which holds DerivedSample class object.
  • The code replaces the DerivedSample class version of fun() method with its Sample class version.
  • It is not possible to hide Sample class version of fun() method without use of new in DerivedSample class.
Show Answer
9. Which of the following statements is correct?
  • The conditional logical operators cannot be overloaded.
  • When a binary operator is overloaded the corresponding assignment operator, if any, must be explicitly overloaded.
  • We can use the default equality operator in an overloaded implementation of the equality operator.
  • A public or nested public reference type does not overload the equality operator.
Show Answer
10. Which of the following operators cannot be overloaded?

    true
    false
    new
    ~
    sizeof
  • 1, 3
  • 2, 4
  • 3, 5
  • All of the above
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test