Juxtapose the use of override with new. What is shadowing?
Answer Posted / nawaz
Using override keyword to a method in the derived class
meaning the method provides a new implementation to the
overridden method (same signature) in the base class. The
base method must be virtual, abstract, or override.
By default a method is not modified by ‘virtual’. So if a
method in derived class wants to override the base
implementation, it needs to be modified by ‘new’ keyword.
This is called shadowing, not overriding. The method in the
derived HIDES the one in the base class.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is sizeof int?
What is a header file?
Explain what are the different file extensions involved when programming in c?
What are identifiers and keywords in c?
Multiply an Integer Number by 2 Without Using Multiplication Operator
Is it better to use a macro or a function?
Is it valid to address one element beyond the end of an array?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
What is a MAC Address?
Is c pass by value or reference?
What is the collection of communication lines and routers called?
What is sizeof c?
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
What are the different types of control structures in programming?