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

why does the array will be start on size 0?

1588


List three things you can do with the files you create by recording your voice on your computer

3139


hi friends, i got selected in tcs, i m doing my b.e in one of the college in coimbatore.. i don have questions to post u.. but i have valid suggestion..its waste to prepare apti for tcs by looking at last 10 year question from internet.they changed all the apti question this year(2009).. but apti questions is easy..prepare critical reasoning for gre 12th edition..mug up the answers in critical reasoning.. u can download ebook for gre 12th edition..solve the critical reasoing question at the same time mug up it.. there were totally 3 critical reasoning question asked.. two for gre 12th edition so if u mug up u can finish two questions in 3 min.. so u will have 27 min for other question so u can work it out and find the ans..above i mentioned as 3 questions tat is 3 question means ,three paargraph.. each para carries 4 question so totally 12 question in critical reasoning.. if u clear all 12 question u will be selected.80% percent sure.then don mug up synonyms from gre barron because they are asking same question from barron but the choice for the questions are changed.. so study synonyms and antonyms from internet.. some pupils have posted the questions.. in tech and h r don use complex word or don show tat u r so dminant.. talk with them how u will speak wit ur friend. u will be through.. don think wat i have posted above is lik some info in other site.. wat i said is true.. they changed apti tis time.. u will be selected if u follow wat i said..again i m saying pls concentrate on critical reasoning.. if all questions in it are right u r through..bye

3290


when did actually oil exploration start

1450


If memory is allocated to a class,when object of the class is created then how do we use the abstract class methods.coz v cant create obj of abstract class, only reference is created,when the abstract class data and members got the space in memory??

1829






what is domain functional level in windows server 2003?

1705


I have completed my B.E with (CSE) computer science and engineering ,i had a total no of backlogs=20 ,is there any chances to get the visa PLEASE HELP ME NE1 : MY ID=john_searchig143@yahoo.com .

1447


synchronous and asynchronous transmission

1486


verbal quiz and answers

1435


what is rapid application development

1296


how the parting surface is selected in injection mould

1485


Box 1 cotain odd value X or Y the box 2 =X i.e 7 or 12 box 3= Y has value 19 if X is 7 or 31 if x is 12 get even value X or Y Use any operator steps allowed 3.

2537


what are the main points to be included in our introduction when asked in hr...??

1474


write a progremme using function 0f prime no.?

1393


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

1576