CMSC132
Abstraction provides - answer high level model of activity
Procedural abstraction - answer Specifies actions performed
hides algorithms
Data abstraction - answer Specifies data objects for the problem
Hides implementations
Encapsulation - answer hides implementation details while providing interface
(methods) for data access
allows us to use code without knowing its implementation
makes debugging and code modification simple
Interface - answer Set of abstract methods
Specifies a contract for a class to implement
Class - answerimplements/defines contract
Collection - answergroups multiple elements into one object
Inheritance - answer- Process in which a derived class (subclass) is created from a
base class (superclass)
- inherits all the superclass methods and instance variables that are marked protected
or public
Creates a hierarchical structure for a group of objects, avoids code duplication
Shadowing - answerOverriding variables in subclasses
Inheritance and private - answerAll private data is inherited by subclasses
However, private members of a superclass cannot be accessed directly
When an object/method is marked protected it is accessible by... - answer- any
subclasses
- any class in the same package
The class Object has these methods... - answerequals(Object other)
toString()
Late (dynamic binding) - answermethod that is called depends on the objects actual
type, not the declared type of the reference variable
Java uses late binding
, Provides more flexibility
Overloading - answerWriting multiple methods of the same name with different number
of parameters/parameter types
Overriding - answerRedefining a method in a subclass
protected access modifier - answerOnly subclasses and classes in the same package
can access
No access modifier (package protected) means class that are _________ can access -
answerIn the same package
Early (static) binding - answermethod that is called depends on the declared type of the
reference variable
More efficient
Abstract class (what and why) - answerClass that cannot create an actual object
Used if logical values cannot be defined for instance variables
public class abstract Animal{
...}
Required if class contains an abstract method
Abstract method - answerProvides method signature
method that does not have any implementation
Why? every subclass will have method (implement in own way)
require abstract class
Cannot be final
What are 3 common uses of Interfaces? - answerPrimary purpose: specifying minimum
functional requirements for a class
Workaround for Java's lack of multiple inheritance
Rare: For defining groups of related symbolic constants
Rules for overriding methods regarding access specifier... - answerDerived class may
change the access specifier, but cannot decrease visibility
How do you disable overriding in derived classes - answerUse "final"
Inner classes (what and why) - answerClass defined in scope of another class
Outer/inner class can access all of each others methods and fields
Has an instance of the outer class object as soon as it is created
Nested Class (what and why) - answerSimilar to inner class but declared "static"
No linkage to outer class
Only access to static methods and fields of outer class
Abstraction provides - answer high level model of activity
Procedural abstraction - answer Specifies actions performed
hides algorithms
Data abstraction - answer Specifies data objects for the problem
Hides implementations
Encapsulation - answer hides implementation details while providing interface
(methods) for data access
allows us to use code without knowing its implementation
makes debugging and code modification simple
Interface - answer Set of abstract methods
Specifies a contract for a class to implement
Class - answerimplements/defines contract
Collection - answergroups multiple elements into one object
Inheritance - answer- Process in which a derived class (subclass) is created from a
base class (superclass)
- inherits all the superclass methods and instance variables that are marked protected
or public
Creates a hierarchical structure for a group of objects, avoids code duplication
Shadowing - answerOverriding variables in subclasses
Inheritance and private - answerAll private data is inherited by subclasses
However, private members of a superclass cannot be accessed directly
When an object/method is marked protected it is accessible by... - answer- any
subclasses
- any class in the same package
The class Object has these methods... - answerequals(Object other)
toString()
Late (dynamic binding) - answermethod that is called depends on the objects actual
type, not the declared type of the reference variable
Java uses late binding
, Provides more flexibility
Overloading - answerWriting multiple methods of the same name with different number
of parameters/parameter types
Overriding - answerRedefining a method in a subclass
protected access modifier - answerOnly subclasses and classes in the same package
can access
No access modifier (package protected) means class that are _________ can access -
answerIn the same package
Early (static) binding - answermethod that is called depends on the declared type of the
reference variable
More efficient
Abstract class (what and why) - answerClass that cannot create an actual object
Used if logical values cannot be defined for instance variables
public class abstract Animal{
...}
Required if class contains an abstract method
Abstract method - answerProvides method signature
method that does not have any implementation
Why? every subclass will have method (implement in own way)
require abstract class
Cannot be final
What are 3 common uses of Interfaces? - answerPrimary purpose: specifying minimum
functional requirements for a class
Workaround for Java's lack of multiple inheritance
Rare: For defining groups of related symbolic constants
Rules for overriding methods regarding access specifier... - answerDerived class may
change the access specifier, but cannot decrease visibility
How do you disable overriding in derived classes - answerUse "final"
Inner classes (what and why) - answerClass defined in scope of another class
Outer/inner class can access all of each others methods and fields
Has an instance of the outer class object as soon as it is created
Nested Class (what and why) - answerSimilar to inner class but declared "static"
No linkage to outer class
Only access to static methods and fields of outer class