Inheritance: 15 flashcards

All 15 flashcards from this kit, free and with no sign-up.

1. Inheritance શું છે?

Show the answer

Inheritance એ OOP નો સિદ્ધાંત છે જે એક class ને બીજા class ના ગુણધર્મો અને પદ્ધતિઓ વારસામાં લેવાની મંજૂરી આપે છે, જે 'is-a' સંબંધ દર્શાવે છે.

2. Parent class અને Child class વચ્ચે શું સંબંધ છે?

Show the answer

Parent class (superclass) પોતાના members child class (subclass) ને આપે છે. Child class parent class ના બધા public અને protected members વારસામાં મેળવે છે અને નવા ઉમેરી શકે છે.

3. Single Inheritance શું છે?

Show the answer

Single Inheritance માં એક child class માત્ર એક parent class માંથી વારસો મેળવે છે. ઉદાહરણ: `Car` → `Vehicle`.

4. Multilevel Inheritance શું છે?

Show the answer

Multilevel Inheritance માં એક class બીજા class માંથી વારસો મેળવે છે, જે પોતે ત્રીજા class માંથી વારસો મેળવે છે. ઉદાહરણ: `SportsCar` → `Car` → `Vehicle`.

5. Hierarchical Inheritance શું છે?

Show the answer

Hierarchical Inheritance માં એક parent class ને બહુવિધ child classes હોય છે. ઉદાહરણ: `Vehicle` → `Car`, `Bike`, `Truck`.

6. Multiple Inheritance શું છે અને તેની મર્યાદા શું છે?

Show the answer

Multiple Inheritance માં એક child class બે કે તેથી વધુ parent classes માંથી વારસો મેળવે છે. કેટલીક ભાષાઓ (જેમ કે Java) આને સીધું સમર્થન આપતી નથી; તેઓ interfaces નો ઉપયોગ કરે છે.

7. Inheritance નો મુખ્ય ફાયદો શું છે?

Show the answer

Inheritance code ને પુનઃઉપયોગી (reusable), સંગઠિત (organized) અને જાળવણી કરવામાં સરળ બનાવે છે. તે polymorphism ને પણ સમર્થન આપે છે.

8. Inheritance અને Composition વચ્ચે શું તફાવત છે?

Show the answer

Inheritance 'is-a' સંબંધ દર્શાવે છે (દા.ત., Dog is an Animal), જ્યારે Composition 'has-a' સંબંધ દર્શાવે છે (દા.ત., Car has an Engine). જ્યાં 'is-a' સંબંધ ન હોય ત્યાં Composition નો ઉપયોગ કરવો જોઈએ.

9. GUI Frameworks માં Inheritance નો ઉપયોગ કેવી રીતે થાય છે?

Show the answer

GUI Frameworks માં, દરેક component (Button, TextField, Label) સામાન્ય રીતે `Component` parent class માંથી વારસો મેળવે છે, જેમાં સામાન્ય ગુણધર્મો (width, height, position) અને પદ્ધતિઓ (draw(), handleEvent()) હોય છે.

10. Inheritance નો ઉપયોગ કરતી વખતે શું ધ્યાન રાખવું જોઈએ?

Show the answer

Inheritance નો ઉપયોગ ફક્ત code reusability માટે ન કરો; 'is-a' સંબંધ જરૂરી છે. ખૂબ ઊંડી inheritance hierarchies ટાળો કારણ કે તે જટિલતા વધારે છે.

11. Child class parent class ના કયા members ને વારસામાં મેળવી શકતો નથી?

Show the answer

Child class parent class ના private members ને વારસામાં મેળવી શકતો નથી. તે ફક્ત public અને protected members ને જ વારસામાં મેળવે છે.

12. Polymorphism સાથે Inheritance નો શું સંબંધ છે?

Show the answer

Inheritance polymorphism ને સમર્થન આપે છે, જ્યાં તમે parent class ના reference દ્વારા child class ના ઑબ્જેક્ટને સંભાળી શકો છો અને યોગ્ય પદ્ધતિ આપમેળે કૉલ થાય છે.

13. Game Development માં Inheritance નો ઉપયોગ કેવી રીતે થાય છે?

Show the answer

Game Development માં, વિવિધ પ્રકારના દુશ્મનો (enemies) એક સામાન્ય `Enemy` class માંથી વારસો મેળવી શકે છે, જેમાં સામાન્ય વર્તણૂકો (move(), attack()) હોય છે, અને પછી દરેક પ્રકાર પોતાની વિશિષ્ટતાઓ ઉમેરે છે.

14. Data Structures માં Inheritance નો ઉપયોગ કેવી રીતે થાય છે?

Show the answer

LinkedList, Stack, Queue જેવા data structures ઘણીવાર વધુ સામાન્ય `List` અથવા `Collection` class માંથી વારસો મેળવે છે, જેમાં સામાન્ય પદ્ધતિઓ (add(), remove(), size()) હોય છે.

15. Inheritance નો ખરો હેતુ શું છે?

Show the answer

Inheritance નો ખરો હેતુ સંબંધોને મોડેલ કરવાનો છે, ફક્ત code ને ફરીથી લખવાનું ટાળવાનો નહીં. જો બે classes વચ્ચે 'is-a' સંબંધ ન હોય, તો Inheritance નો ઉપયોગ કરવો યોગ્ય નથી.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages