DATA STRUCTURES: EXAM 1
QUESTIONS & ANSWERS
Classes - Correct Answers -Blueprints for our data, structure allows for encapsulation of
data and operations of new type together.
Data Abstraction - Correct Answers -Concept that says the user of the class knows the
nature of the data and the public methods, but not the implementation details.
Protected - Correct Answers -Declaration keyword that means data is only accessible
within a class and subclass within the same package.
Static - Correct Answers -Declaration keyword that means the data or method is part of
the class rather than instance; shared by all instances.
Final - Correct Answers -Declaration keyword that means the data cannot be assigned
(variables), overridden (methods) or subclassed (classes).
Dynamically - Correct Answers -All objects in Java are allocated ______. Memory is
allocated using the new operator. Once allocated, objects exist for an indefinite period
of time.
Composition - Correct Answers -Method by which we build new classes using
components (instance variables) that are from previously defined classes. "Has a"
relationship between new class and old classes.
Inheritance - Correct Answers -Method by which we build a new class(subclass) by
extending a previously defined class (superclass). Subclass has all the properties (data
and methods) defined in the superclass.
"is a" relationship between the subclass and superclass.
Subclass is a superclass, and subclass objects can be assigned to superclass
variables.
Foo f1;
SubFoo;
f1=new Foo //fine
f1=new subFoo//fine
f1.subfoometh //NO!
-need to cast
s1=new subFoo/ fine
s1.subfoomethod//fine
s1.foomethod//fine
, s1=new Foo() illegal
Polymorphism - Correct Answers -Concept implemented through method overriding and
dynamic (or late) binding. Allows for access collections of mixed data types consistently.
Method overriding - Correct Answers -Polymorphism idea that involves:
A method defined in a superclass is redefined in a subclass with an identical method
signature.
Since the signatures are identical, rather than overloading the method (ad hoc
polymorphism), it is instead overring the method.
(superclass version can still be accessed via the super reference).
Ad Hoc polymorphism - Correct Answers -Overloading method signatures but keeping
the method title the same
Dynamic or late binding - Correct Answers -Polymorphism idea that includes:
Code executed for a method call is associated with the call during RUN-TIME
The actual method executed is determined by the TYPE of the object, not the type of
reference
Abstract classes - Correct Answers -A class that is like an interface but comes with
partial implementation. No objects of the class will ever be defined. But the instance
data and methods will still be inherited by all subclasses.
Interfaces - Correct Answers -A named set of methods with no instance data. Used as a
contract.
No static constants are allowed or instance data.
Instance methods have no bodies and not interfaces will be instantiated.
A given class can implement multiple interfaces.
ONLY INTERFACE METHODS ARE ACCESSIBLE THROUGH THE INTERFACE
REFERENCE
Abstract Data Types - Correct Answers -Data types that require only understanding the
nature of the data without a need for knowing how it is implemented.
Functionality is separated from its implementation.
Classes are the language specific implementations of ADTs
Bags - Correct Answers -ADT that has:
no rule for how many items to put in
no rule for order
duplicates can happen
number of items is tracked.
Recursion - Correct Answers -Idea:
Some problem P is defined in terms of one or more subP problems, which are identical
in nature to P but smaller in size
QUESTIONS & ANSWERS
Classes - Correct Answers -Blueprints for our data, structure allows for encapsulation of
data and operations of new type together.
Data Abstraction - Correct Answers -Concept that says the user of the class knows the
nature of the data and the public methods, but not the implementation details.
Protected - Correct Answers -Declaration keyword that means data is only accessible
within a class and subclass within the same package.
Static - Correct Answers -Declaration keyword that means the data or method is part of
the class rather than instance; shared by all instances.
Final - Correct Answers -Declaration keyword that means the data cannot be assigned
(variables), overridden (methods) or subclassed (classes).
Dynamically - Correct Answers -All objects in Java are allocated ______. Memory is
allocated using the new operator. Once allocated, objects exist for an indefinite period
of time.
Composition - Correct Answers -Method by which we build new classes using
components (instance variables) that are from previously defined classes. "Has a"
relationship between new class and old classes.
Inheritance - Correct Answers -Method by which we build a new class(subclass) by
extending a previously defined class (superclass). Subclass has all the properties (data
and methods) defined in the superclass.
"is a" relationship between the subclass and superclass.
Subclass is a superclass, and subclass objects can be assigned to superclass
variables.
Foo f1;
SubFoo;
f1=new Foo //fine
f1=new subFoo//fine
f1.subfoometh //NO!
-need to cast
s1=new subFoo/ fine
s1.subfoomethod//fine
s1.foomethod//fine
, s1=new Foo() illegal
Polymorphism - Correct Answers -Concept implemented through method overriding and
dynamic (or late) binding. Allows for access collections of mixed data types consistently.
Method overriding - Correct Answers -Polymorphism idea that involves:
A method defined in a superclass is redefined in a subclass with an identical method
signature.
Since the signatures are identical, rather than overloading the method (ad hoc
polymorphism), it is instead overring the method.
(superclass version can still be accessed via the super reference).
Ad Hoc polymorphism - Correct Answers -Overloading method signatures but keeping
the method title the same
Dynamic or late binding - Correct Answers -Polymorphism idea that includes:
Code executed for a method call is associated with the call during RUN-TIME
The actual method executed is determined by the TYPE of the object, not the type of
reference
Abstract classes - Correct Answers -A class that is like an interface but comes with
partial implementation. No objects of the class will ever be defined. But the instance
data and methods will still be inherited by all subclasses.
Interfaces - Correct Answers -A named set of methods with no instance data. Used as a
contract.
No static constants are allowed or instance data.
Instance methods have no bodies and not interfaces will be instantiated.
A given class can implement multiple interfaces.
ONLY INTERFACE METHODS ARE ACCESSIBLE THROUGH THE INTERFACE
REFERENCE
Abstract Data Types - Correct Answers -Data types that require only understanding the
nature of the data without a need for knowing how it is implemented.
Functionality is separated from its implementation.
Classes are the language specific implementations of ADTs
Bags - Correct Answers -ADT that has:
no rule for how many items to put in
no rule for order
duplicates can happen
number of items is tracked.
Recursion - Correct Answers -Idea:
Some problem P is defined in terms of one or more subP problems, which are identical
in nature to P but smaller in size