Quiz: Object-Oriented Programming Foundations — 11 questions

Detailed questions and answers

1. What is the defining execution pattern of procedural programming?

It organizes software around interfaces that hide implementation details
It organizes instructions as procedures executed from top to bottom
It organizes programs as classes that inherit shared attributes
It organizes data and behavior as objects representing entities

It organizes instructions as procedures executed from top to bottom

Explanation

Procedural programming expresses a solution as a sequence of procedures and executes instructions from top to bottom. Organizing data and behavior into objects describes object-oriented programming instead.

2. What is procedural programming primarily characterized by?

Inheritance and polymorphism for code reuse
Use of classes and objects to organize data and behavior
Encapsulation of data and functions into a single unit
A sequence of steps or procedures executed from top to bottom

A sequence of steps or procedures executed from top to bottom

Explanation

Procedural programming is mainly characterized by writing a program as a sequence of steps or procedures that execute in order. Unlike object-oriented programming, it does not focus on data organization around objects or classes.

3. Which situation best illustrates a major limitation of procedural programming?

A small program becomes easy to learn because it uses straightforward functions
A large program becomes difficult to maintain because its code sections depend on one another
A simple task becomes clear because its instructions execute in a predictable sequence
A medium-sized program becomes reusable because its procedures can be called repeatedly

A large program becomes difficult to maintain because its code sections depend on one another

Explanation

Large procedural programs can become difficult to maintain because dependencies between code sections increase as the program grows. Ease of learning, function reuse, and predictable execution are recognized strengths rather than limitations.

4. Which of the following is a main limitation of procedural programming?

Easy maintenance in large programs
Supports data security
Suitable for real-world applications
Difficult code reuse

Difficult code reuse

Explanation

Difficult code reuse is a primary limitation of procedural programming, as it executes steps sequentially and does not inherently support organizing code around reusable entities. The other options are advantages or characteristics of procedural programming, not limitations.

5. How does object-oriented programming represent a real-world entity in a program?

It stores the entity's behavior in reusable functions without associating it with data
It represents the entity as a top-to-bottom sequence of independent instructions
It separates the entity's data from the procedures that operate on that data
It combines the entity's data and the functions operating on that data within an object

It combines the entity's data and the functions operating on that data within an object

Explanation

Object-oriented programming combines data and the functions that operate on it within an object representing a real-world entity. Separating data from its operating procedures is characteristic of the procedural approach.

6. What is the main purpose of classes in object-oriented programming?

To execute procedures sequentially without reusing code.
To replace functions with more efficient algorithms.
To directly store data in memory without defining structure.
To serve as a blueprint for creating objects that contain data members and member functions.

To serve as a blueprint for creating objects that contain data members and member functions.

Explanation

Classes serve as blueprints for creating objects, defining their data and behavior. The other options are incorrect because classes do not directly store data without objects, do not replace functions, and are not solely for sequential execution.

7. In a car object, which classification correctly distinguishes attributes from methods?

Color, brand, and model are methods; Start() and Stop() are attributes
Start(), Stop(), Accelerate(), and Brake() are attributes; color and brand are methods
Color, brand, model, and speed are attributes; Start() and Brake() are methods
Speed, Start(), and Stop() are attributes; brand and Accelerate() are methods

Color, brand, model, and speed are attributes; Start() and Brake() are methods

Explanation

Attributes describe an object's data, so color, brand, model, and speed belong to the car's attributes. Methods describe behavior, so operations such as Start() and Brake() are methods rather than attributes.

8. When was the concept of encapsulation, abstraction, and hiding formally introduced as fundamental principles in object-oriented programming?

In the 1970s, during the creation of Simula, the first object-oriented language.
In the 1960s, alongside the development of early programming languages like FORTRAN.
In the early 1980s, with the development of C++ and Smalltalk.
In the late 1990s, with the rise of Java and C#.

In the 1970s, during the creation of Simula, the first object-oriented language.

Explanation

Encapsulation, abstraction, and hiding were formalized as core principles with the advent of languages like Simula in the 1960s, which introduced object-oriented concepts. The 1980s saw their widespread adoption and formalization in languages like C++ and Smalltalk, making this the most accurate time period for their formal introduction.

9. How do inheritance and polymorphism differ in object-oriented programming?

Inheritance is used to hide data, whereas polymorphism is used to encapsulate data within classes.
Inheritance involves binding methods at compile time, whereas polymorphism involves binding methods at runtime.
Inheritance is a mechanism for message passing, while polymorphism is a way to organize data and behavior around objects.
Inheritance allows a class to derive properties from another, promoting code reuse, while polymorphism enables objects to behave differently based on their actual class.

Inheritance allows a class to derive properties from another, promoting code reuse, while polymorphism enables objects to behave differently based on their actual class.

Explanation

Inheritance allows a class to derive properties from another class, promoting code reuse, while polymorphism enables objects to behave differently depending on their actual class, providing flexibility in method behavior.

10. Who is credited with formalizing the concept of message passing and binding in object-oriented programming?

Dennis Ritchie
Bjarne Stroustrup
James Gosling
Alan Kay

Alan Kay

Explanation

Alan Kay is credited with proposing the fundamental concepts of object-oriented programming, including message passing and binding. Bjarne Stroustrup developed C++, James Gosling created Java, and Dennis Ritchie designed C, but they are not specifically credited with formalizing message passing in OOP.

11. What is a primary effect of using object-oriented programming in software development?

It discourages the use of inheritance and polymorphism.
It makes code more difficult to maintain.
It eliminates the need for data security measures.
It enhances code reuse and reduces redundancy.

It enhances code reuse and reduces redundancy.

Explanation

Object-oriented programming primarily promotes code reuse and reduces data redundancy through features like inheritance. The distractor suggesting it makes code more difficult to maintain is incorrect, as OOP actually simplifies maintenance by organizing code into reusable classes.

Review with flashcards

Memorize the answers with 12 flashcards on Object-Oriented Programming Foundations.

What is a programming language used for?

To write instructions and tell a computer how to perform tasks.

Programming Paradigm

Approach to solving problems with code

What is procedural programming?

An approach writing programs as sequences of steps executing top to bottom.

See flashcards →

Read the study sheet

Read the complete study sheet on Object-Oriented Programming Foundations.

See study sheet →

Similar courses

Create your own quizzes

Import your course and AI generates quizzes with corrections in 30 seconds.

Quiz generator