what is the term genericity in oops?

Answer Posted / akshata

Abstraction of structure independently of type is genericity
(pronounced jen-err-iss-it-ee).

E.g. Compare these two functions to return the maximum of
two numbers.

integer maxInteger (integer param1, integer param2)
{
if (param1 > param2)
{ return param1; }

return param2;
}



float maxFloat (float param1, float param2)
{
if (param1 > param2)
{ return param1; }

return param2;
}

It seems silly to have to write the two functions but if a
language doesn't allow you to pass an integer to a function
that requires a floating point parameter (or vice versa)
then this is exactly what you must do.

Some languages allow you to to write a single generic
function that will serve the same purpose for both integers
and floating point values (or any other types you like for
that matter). In general, such a function might look a
little like this.

TYPE max (TYPE param1, TYPE param2)
{
if (param1 > param2)
{ return param1; }

return param2;
}

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

operation of carrier aided protection and what is the basis for choice of frequncy in powerline carrier system

5937


I am selected interview for computer sc.please give me some information how many types question asked in interview.my id is sumanadas10@gmail.com

1341


explain inflation ,deprication ,time of value & pf tariff

1854


what is difference between shell commands and shell scripting commands or both r same?

1611


HOW CAN YOU RELATE THE FUNCTION WITH STRUCTURE EXPLAIN WITH APPROPRIATE EXAMPLES

1388






I am helping a friend to design a concert hall. No need for super architectural show off. Just a rectangular box. Knowing that in my country constructions are done with reinforced concrete and concrete blocks and that the hall's dimensions are, length: 75 meters, width: 32m height: 9m, and that there should not be any columns inside, what would be the size of the columns, beams and roof slab ?

1290


how to delete four out of five duplicate records in a table using sql

1446


when load increase in generator in island mode, why turbine rpm is reduced

3043


Hi dost here Alok Kumar please send question pattern for NIC at godinall.kumar1@gmail.com or alok.iitb07@gmail.com

1411


CSS corp interview process and placement papers

1495


Name a accredited or govt approved university which have 100% online engineering course

1319


why one should join accenture?

2368


what is the working of tcp/ip?

1542


hi ,,,,I m going to attend corporate bank exam of specialist IT officer, I don't Know What type of question arise in interview..some suggest me my email id is surinder.singh.btech@gmail.com

1562


Implement the dictionary operations INSERT, DELETE, and SEARCH using singly linked, circular lists. What are the running times of your procedures?

4992