Computer Science 109 : Introduction to
Programming
You are designing a program instance; Semi class
for vehicles. Some of the Explanation: A new semi is an instance of the Semi class. It
class names include Semi, is an object. This is the basis of object-oriented
Compact, and SUV. If we programming, the collection of classes and objects.
create a new semi, it is said
that the semi is a(n)_______of
a(n)
_____.
You have designed a Methods.
hierarchy of classes for Explanation: Methods are the functions or the actual tasks being
accounting software. All carried out.
parent/child class
relationships are set. What
will you need for the classes
to actually perform tasks?
A parent class called Polymorphism.
SoftDrink has a brew() Explanation: Polymorphism refers to being able to perform
method. RootBeer and Beer the same thing but differently. Root beer is brewed, but not
classes inherit from SoftDrink. in the same way as beer. Yet each can use the brew()
Each uses the brew() method method in different ways.
but in different ways. Which
aspect of object-oriented
design is this?
You are designing a program encapsulation
for payroll. The Tax class has Explanation: We need to hide the data or encapsulate it.
a method to calculate tax You can still call the calculateTax() method in the Tax class,
rates based on pay. You without having to know exactly how the tax is being
want to keep this method calculated, or even what the employee pay rate is. It's
and its variables invisible to good practice to keep things restricted/encapsulated.
other classes. They can Start with the tightest controls.
access the method but don't
get to see its details. This is
an example of _.
, An object-oriented design Inheritance.
consists of periodical and Explanation: Just as you inherited traits from your
publication data. The forebears, child classes (sub- classes) inherit methods and
hierarchy of classes, from fields from a parent class.
top to bottom is as follows:
Publication -> Book -> Novel.
If the Novel class gains all
methods and fields from the
Book class, this is an
example of which of the
concepts of Object Oriented
Design?
A___is a procedure associated method
with a Explanation: A method is a procedure associated with a
class that describes an action class and defines the behavior of the objects that are
an object is able to perform. created from the class.
objects.
Sally is continuing work on
Explanation: An object is a component of a program that
her Object- Oriented
knows how to perform certain actions and how to interact
Program and is writing code
with other elements of the program. Objects are the basic
for a car, truck, and bus.
units of object-oriented programming. The items that fall
These items under the class
under the class of vehicles (car, truck, and bus) are
called vehicle are referred to
referred to as objects.
as
______________________________
_.
Sally is writing some Object- class
Oriented Program code for a
vehicle that contains the
attributes manufacturer,
color, and price, along with
what she wants the vehicle to
be able to do which includes
start, drive, and park. To do
this, she needs to create a
____________for vehicles.
How do functions differ from Functions are independent of classes, and methods are defined within
methods? a class.
Inference.
Which of the following is NOT Explanation: Four core concepts of object-oriented
a core concept of object- programming are abstraction, encapsulation, inheritance
oriented programming? and polymorphism. Note that inference is NOT a core
concept.
The line of code that creates constructor.
an object from the class is Explanation: A constructor creates an object, or instance, of the class.
called a _____
Programming
You are designing a program instance; Semi class
for vehicles. Some of the Explanation: A new semi is an instance of the Semi class. It
class names include Semi, is an object. This is the basis of object-oriented
Compact, and SUV. If we programming, the collection of classes and objects.
create a new semi, it is said
that the semi is a(n)_______of
a(n)
_____.
You have designed a Methods.
hierarchy of classes for Explanation: Methods are the functions or the actual tasks being
accounting software. All carried out.
parent/child class
relationships are set. What
will you need for the classes
to actually perform tasks?
A parent class called Polymorphism.
SoftDrink has a brew() Explanation: Polymorphism refers to being able to perform
method. RootBeer and Beer the same thing but differently. Root beer is brewed, but not
classes inherit from SoftDrink. in the same way as beer. Yet each can use the brew()
Each uses the brew() method method in different ways.
but in different ways. Which
aspect of object-oriented
design is this?
You are designing a program encapsulation
for payroll. The Tax class has Explanation: We need to hide the data or encapsulate it.
a method to calculate tax You can still call the calculateTax() method in the Tax class,
rates based on pay. You without having to know exactly how the tax is being
want to keep this method calculated, or even what the employee pay rate is. It's
and its variables invisible to good practice to keep things restricted/encapsulated.
other classes. They can Start with the tightest controls.
access the method but don't
get to see its details. This is
an example of _.
, An object-oriented design Inheritance.
consists of periodical and Explanation: Just as you inherited traits from your
publication data. The forebears, child classes (sub- classes) inherit methods and
hierarchy of classes, from fields from a parent class.
top to bottom is as follows:
Publication -> Book -> Novel.
If the Novel class gains all
methods and fields from the
Book class, this is an
example of which of the
concepts of Object Oriented
Design?
A___is a procedure associated method
with a Explanation: A method is a procedure associated with a
class that describes an action class and defines the behavior of the objects that are
an object is able to perform. created from the class.
objects.
Sally is continuing work on
Explanation: An object is a component of a program that
her Object- Oriented
knows how to perform certain actions and how to interact
Program and is writing code
with other elements of the program. Objects are the basic
for a car, truck, and bus.
units of object-oriented programming. The items that fall
These items under the class
under the class of vehicles (car, truck, and bus) are
called vehicle are referred to
referred to as objects.
as
______________________________
_.
Sally is writing some Object- class
Oriented Program code for a
vehicle that contains the
attributes manufacturer,
color, and price, along with
what she wants the vehicle to
be able to do which includes
start, drive, and park. To do
this, she needs to create a
____________for vehicles.
How do functions differ from Functions are independent of classes, and methods are defined within
methods? a class.
Inference.
Which of the following is NOT Explanation: Four core concepts of object-oriented
a core concept of object- programming are abstraction, encapsulation, inheritance
oriented programming? and polymorphism. Note that inference is NOT a core
concept.
The line of code that creates constructor.
an object from the class is Explanation: A constructor creates an object, or instance, of the class.
called a _____