Exercise: Polymorphism
Questions for: Polymorphism
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
Answer: B
No answer description is available. Let's discuss.
Which of the following operators cannot be overloaded?
- true
- false
- new
- ~
- sizeof
A:
1, 3
B:
2, 4
C:
3, 5
D:
All of the above
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
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.
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
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.
A:
1, 3
B:
2, 4
C:
2, 5
D:
3, 4
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following 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 )
Answer: D
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.