,1. Multiple Choice: Which principle of object-oriented
programming is demonstrated by the ability of different classes to
use the same interface?
a) Encapsulation
b) Abstraction
c) Polymorphism
d) Inheritance
Correct Answer: c) Polymorphism
Rationale: Polymorphism allows objects of different classes to
be treated as objects of a common superclass, particularly through
the use of a shared interface.
2. Fill-in-the-Blank: An __________ is a blueprint from which
individual objects are created in object-oriented programming.
Correct Answer: Class
Rationale: A class is a template or blueprint that defines the
variables and the methods common to all objects of a certain kind.
3. True/False: In object-oriented programming, encapsulation is
solely concerned with the internal workings of a class and does
not affect its external interface.
Correct Answer: False
, Rationale: While encapsulation does involve the internal
workings of a class, it also defines the external interface through
which the class interacts with other parts of the program.
4. Multiple Response: Select all that apply. Which of the
following are benefits of using inheritance in object-oriented
programming?
a) Code reusability
b) Increased program complexity
c) Easier maintenance
d) Tight coupling
Correct Answers: a) Code reusability, c) Easier maintenance
Rationale: Inheritance promotes code reusability and easier
maintenance by allowing new classes to adopt the properties of
existing ones. Increased program complexity and tight coupling
are generally considered disadvantages.
5. Multiple Choice: What is the term used to describe a class that
cannot be instantiated but can be subclassed?
a) Concrete class
b) Abstract class
c) Final class
d) Static class
, Correct Answer: b) Abstract class
Rationale: An abstract class cannot be instantiated on its own
and is intended to be subclassed, where its methods can be
implemented.
6. Fill-in-the-Blank: The process by which one object acquires the
properties of another object is known as __________.
Correct Answer: Inheritance
Rationale: Inheritance is the mechanism in OOP by which one
class is allowed to inherit the features (properties and methods) of
another class.
7. True/False: The 'this' keyword in object-oriented programming
is used to reference the current class instance.
Correct Answer: True
Rationale: The 'this' keyword is a reference to the current object,
used within a class to refer to the current instance of that class.
8. Multiple Response: Which of the following statements are true
regarding static methods in object-oriented programming?
a) They can be called without creating an instance of the class
b) They can access instance variables directly
c) They belong to the class, rather than any object instance
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller EmilioOchieng. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $12.49. You're not tied to anything after your purchase.