Save
computer science
object oriented programming
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Makeila Fuller
Visit profile
Cards (30)
What is a class in programming?
A class forms a blueprint to
instantiate
/create an
object
.
View source
What is a subclass?
A subclass is below a
superclass
in the class hierarchy.
View source
What does a subclass inherit from a superclass?
A subclass inherits all of the
attributes
and
methods
of the superclass.
View source
Can a subclass have its own attributes and methods?
Yes
View source
What is the relationship between a subclass and a superclass?
A subclass is a
specialized
version of a superclass.
It inherits all
features
of the superclass.
It can have additional features, making it more specific.
View source
What are the characteristics of multiple subclasses in inheritance?
Each subclass can inherit from the same
superclass
.
Examples include `Dog`, `Cat`, and `Bird`
inheriting
from `Animal`.
They can share common
behavior
while defining their own specific
behaviors.
View source
What is polymorphism in programming?
Polymorphism allows treating different
subclasses
as instances of the
superclass
.
View source
How can polymorphism be demonstrated with a list of objects?
You can create a list of `Animal`
objects
that includes `Dog`, `Cat`, and `Bird` and call the `speak`
method
on each.
View source
What are the benefits of having a superclass with multiple subclasses?
A superclass can have multiple subclasses with specific
attributes
and
methods
.
This allows for
flexible
and
organized
code structure.
Enables
reuse
of common functionality while allowing
specialized
behavior in subclasses.
View source
What is a common interface in polymorphism?
A common interface is a method defined in the
superclass
that
subclasses
can override.
View source
What does it mean for objects to be interchangeable in polymorphism?
Interchangeable objects can be used in collections as long as they share the same
superclass
.
View source
What are methods in the context of classes?
Methods are
subroutines
(functions) that allow the object to perform actions.
View source
What are attributes in the context of classes?
Attributes
are
variables
that
describe
the
object.
View source
How are classes created in Java?
Classes
are
created
using
the
`
class
` keyword.
View source
What does the `public` keyword signify in Java classes?
The `
public
` keyword means
anyone
can
access
the class from any part of the
code.
View source
How are class methods accessed in Java?
Class methods are accessed using
dot notation
.
View source
What keyword is used to create an object in Java?
The keyword used to create an object is `
new
`.
View source
What is encapsulation in programming?
Encapsulation means keeping data safe from direct modification.
It is often known as
information hiding
.
View source
Can an instance of a class alter the data of another instance of the same class?
No
, an
instance
of a
class
cannot alter the data of another
instance
of the same
class.
View source
Is the statement "An instance of a class can alter the data of another instance of the same class" true or false?
False
View source
What is polymorphism in object-oriented programming?
Polymorphism is when a
subclass
alters its inherited methods by
overloading
or
overriding
.
View source
What are the two ways a subclass can alter its inherited methods?
Overloading
Overriding
View source
What does the `Shape` superclass define?
The `Shape` superclass defines a generic `
area
` method.
View source
How do the `Circle` and `Triangle` subclasses implement the `area` method?
They
define
their
own
versions of `area` with different
parameter
lists.
View source
What is the parameter list for the `Circle.area` method?
The `Circle.area` method takes one argument, `
radius
`.
View source
What is the parameter list for the `Triangle.area` method?
The `Triangle.area` method takes two
arguments
, `
base
` and `
height
`.
View source
What is method overloading?
Methods with the same name but different
parameter lists
Allows similar
operations
for different types of
shapes
View source
Why is overloading beneficial in programming?
Overloading makes code more
flexible
and easier to maintain.
View source
What is method overriding?
Subclass refines or customizes behavior defined by the
superclass
Useful for specific needs of the
subclass
View source
When is overriding particularly useful?
When a
superclass
defines a general behavior that needs refinement in a
subclass
.
View source