• Polymorphism - General Questions
6. 

Which of the followings is the correct way to overload + operator?

A.
public sample operator + ( sample a, sample b )
B.
public abstract operator + ( sample a, sample b)
C.
public abstract sample operator + (sample a, sample b )
D.
public static sample operator + ( sample a, sample b )
E. All of the above

7. 

Which of the following statements are correct?

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

A. 1, 3
B. 2, 4
C. 2, 5
D. 3, 4

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()
    { }
}

A. DerivedSample class hides the fun() method of base class.
B. The DerivedSample class version of fun() method gets called using Sample class reference which holds DerivedSample class object.
C. The code replaces the DerivedSample class version of fun() method with its Sample class version.
D. It is not possible to hide Sample class version of fun() method without use of new in DerivedSample class.

9. 

Which of the following operators cannot be overloaded?

  1. true
  2. false
  3. new
  4. ~
  5. sizeof

A. 1, 3
B. 2, 4
C. 3, 5
D. All of the above

10. 

Which of the following modifier is used when a virtual method is redefined by a derived class?

A. overloads
B. override
C. overridable
D. virtual
E. base