235k views
0 votes
When designing an object-oriented program and writing classes, it is common practice to:

a) Use encapsulation
b) Use inheritance
c) Use global variables
d) Use procedural programming

User Dellowar
by
8.1k points

1 Answer

0 votes

Final answer:

When writing classes in object-oriented programming, common practices include using encapsulation and inheritance while avoiding global variables and procedural programming. Encapsulation secures data, and inheritance allows for hierarchy and reuse.

Step-by-step explanation:

When designing an object-oriented program and writing classes, it is common practice to:

  • Use encapsulation
  • Use inheritance
  • Avoid using global variables, as this is not considered a best practice in object-oriented design
  • Avoid the reliance on procedural programming since object-orientation is a different paradigm

Encapsulation is one of the four fundamental OOP concepts and is used to hide the internal states and functionalities of an object, exposing only what is necessary through a well-defined interface. Inheritance is another key OOP concept that allows classes to inherit properties and behaviors from other classes. It's important to minimize the use of global variables in OOP because they break encapsulation and can lead to code that is difficult to maintain and debug. Lastly, object-oriented programming is typically favored over procedural programming within the context of OOP because it provides a structure that is more modular and scalable due to its use of objects and classes.

User Deepak Puthraya
by
8.5k points