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 is necking in production engineering ?

0 Answers   Essar,


what are the steps u follow to create an custom idoc program in which environment u create the program?

0 Answers   HCL,


to write a program to search a character in a string and to print till the character in the string using pointers in c program

1 Answers  


what is elligibility criteria of hcl?

0 Answers   HCL,


defference between menu and context menu in vb.net?

0 Answers  






synchronous and asynchronous transmission

0 Answers  


Please mail me the sample papers of PNB for the post Dy. Manager.

0 Answers  


how to connect oracle with java ? Give detail explanation.

0 Answers   Bata,


i want a richdatatable to be displayed only when a list has some value in the bean, and a datatable with header only if the list is empty. And i want the datatable to be printed only when ajax button is clicked??

0 Answers  


How To Servers For Malitnationl Bank?

0 Answers  


difference between a for loop and a while loop? what are its uses in c language?

0 Answers  


PREVIOUS AND NEW companies positive and negative points AFTER LIVING

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)