CSharp Programming

CSharp Programming

Polymorphism has 13 Questions

Which of the following unary operators can be overloaded?
  1. true
  2. false
  3. +
  4. new
  5. is

1, 2, 3
3, 4, 5
3 only
5 only
A derived class can stop virtual inheritance by declaring an override as

inherits
extends
inheritable
sealed
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
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.
Which of the following keyword is used to overload user-defined types by defining static member functions?

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

public sample operator + ( sample a, sample b )
public abstract operator + ( sample a, sample b)
public abstract sample operator + (sample a, sample b )
public static sample operator + ( sample a, sample b )
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.

1, 3
2, 4
2, 5
3, 4
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.
Which of the following operators cannot be overloaded?
  1. true
  2. false
  3. new
  4. ~
  5. sizeof

1, 3
2, 4
3, 5
All of the above
Which of the following modifier is used when a virtual method is redefined by a derived class?

overloads
override
overridable
virtual
In order for an instance of a derived class to completely take over a class member from a base class, the base class has to declare that member as

new
base
virtual
overrides
Which of the following can be declared as a virtual in a class?
  1. Methods
  2. Properties
  3. Events
  4. Fields
  5. Static fields

1, 2, 3
3, 5
2, 4
2, 3, 5
Which of the following are necessary for Run-time Polymorphism?
  1. The overridden base method must be virtual, abstract or override.
  2. Both the override method and the virtual method must have the same access level modifier.
  3. An override declaration can change the accessibility of the virtual method.
  4. An abstract inherited property cannot be overridden in a derived class.
  5. An abstract method is implicitly a virtual method.

1, 3
1, 2, 5
2, 3, 4
4 only