VT CS 2114 Exam 1 Review questions
well answers
A Primitive Type represents - correct answer ✔✔ Single indecomposable value
A Reference Type represents - correct answer ✔✔ memory address instead of a value
scope (error) - correct answer ✔✔ visibility of variables
the operator == tests - correct answer ✔✔ if two variables reference the same memory location
a class uses composition when it - correct answer ✔✔ declares an instance of another class as a
data field
composition relationship - correct answer ✔✔ "has-a"
inheritance relationship - correct answer ✔✔ "is-a"
why is it good to use inheritance? - correct answer ✔✔ to have a general class with common
properties and behaviors shared by multiple other classes
calls constructor of parent class - correct answer ✔✔ super();
calls constructor of current class - correct answer ✔✔ this();
, what happens when one method has the same name as another but different parameters -
correct answer ✔✔ method overloaded
key benefit of inheritance - correct answer ✔✔ an object can have several types
encapsulation - correct answer ✔✔ a design principle that hides data and methods
abstraction - correct answer ✔✔ focus on "what", not "how"
client interface - correct answer ✔✔ what code the client needs to know to properly use the
class
implementation - correct answer ✔✔ all data fields and details of methods
interface type can reference... - correct answer ✔✔ any object of a class that implements that
interface
a generic data type is preferred over using an object because... - correct answer ✔✔ it ensures
all members of collection are related by inheritance
what is a behavior not represented in a bag? - correct answer ✔✔ reordering the bag
what method returns the current number of items in a bag - correct answer ✔✔
getCurrentSize()
when would the add method return false? - correct answer ✔✔ when the addition of a new
item was not successful
well answers
A Primitive Type represents - correct answer ✔✔ Single indecomposable value
A Reference Type represents - correct answer ✔✔ memory address instead of a value
scope (error) - correct answer ✔✔ visibility of variables
the operator == tests - correct answer ✔✔ if two variables reference the same memory location
a class uses composition when it - correct answer ✔✔ declares an instance of another class as a
data field
composition relationship - correct answer ✔✔ "has-a"
inheritance relationship - correct answer ✔✔ "is-a"
why is it good to use inheritance? - correct answer ✔✔ to have a general class with common
properties and behaviors shared by multiple other classes
calls constructor of parent class - correct answer ✔✔ super();
calls constructor of current class - correct answer ✔✔ this();
, what happens when one method has the same name as another but different parameters -
correct answer ✔✔ method overloaded
key benefit of inheritance - correct answer ✔✔ an object can have several types
encapsulation - correct answer ✔✔ a design principle that hides data and methods
abstraction - correct answer ✔✔ focus on "what", not "how"
client interface - correct answer ✔✔ what code the client needs to know to properly use the
class
implementation - correct answer ✔✔ all data fields and details of methods
interface type can reference... - correct answer ✔✔ any object of a class that implements that
interface
a generic data type is preferred over using an object because... - correct answer ✔✔ it ensures
all members of collection are related by inheritance
what is a behavior not represented in a bag? - correct answer ✔✔ reordering the bag
what method returns the current number of items in a bag - correct answer ✔✔
getCurrentSize()
when would the add method return false? - correct answer ✔✔ when the addition of a new
item was not successful