what is the term genericity in oops?



what is the term genericity in oops?..

Answer / 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

More Engineering AllOther Interview Questions

what are the differences between one dimensional ram and two dimensional ram?

0 Answers  


A polynomials in mamory can be represented by____________

0 Answers  


could i know the selection pattern at hpcl, am an undergradute in chemical technology, but my sujects or course do not figure out antwhere on the lists.

0 Answers  


what are the differences between structures and arrays in c language?

1 Answers  


How would Nvidia increase the core clock speed anymore?

0 Answers  






What is the procedure for taking leave while detecting Epf and Esi?

0 Answers  


Guys! I coplted 10th with 80% and +2 with 64% now am dng c.s.e b.tech...i want to go abroad for higher studies i want to write tofel...plZ GIVE UR SUGGESTIONS!

0 Answers  


write a pgm to accept an array of names & name & check whether the name is present in the array. return the count of occurance. use following array as input; {"Dave","Ann","dev","merry"}

0 Answers  


what is the maximum load for MDB, SMDB & DB

1 Answers   Target,


which is better php,asp.net,jsp? and why?

0 Answers  


Please if anybody have Vizag Steel Entrance exam papers or atleast Pattern of exam.Then please forward to my email- id: :srikanth.avanthi@gmail.com

0 Answers  


defference between menu and context menu in vb.net?

0 Answers  


Categories
  • Civil Engineering Interview Questions Civil Engineering (5085)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4451)
  • Electrical Engineering Interview Questions Electrical Engineering (16632)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)