Advanced Inheritance Concepts Flashcards

(34 cards)

1
Q

Abstract class

A

It cannot create any concrete objects and usually has one or more empty abstract methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Unique characteristic of abstract class

A
  • It cannot be instantiated in the main class
  • has one or more empty abstract methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Abstract method

A

no body, no curly braces, no method statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Subclass of abstract class

A

inherits abstract method from parent
- the subclass will code to override empty superclass method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Dynamic Method Binding

A

Every subclass object “is a” superclass member
- it converts subclass objects into superclass objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A.k.a. late binding; the ability to select correct subclass method to make programs flexible

A

Dynamic Method Binding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Using Superclass as a Parameter Type

A

Using the superclass as method argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Arrays of Subclass Objects

A

Create array of different objects but share the same ancestry. This is to reserve memory for multiple object references.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Using Object Class

A

Every Java class is an extension of Object class
* imported automatically
* includes method to use or override

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Creates and returns a copy of this object

A

Object clone()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Indicates if an object is equal to the parameter object

A

boolean equals(Object obj)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

garbage collector on an object when there are no more references to the object

A

void finalize()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Returns the class to which this object belongs in runtime

A

Class<?> getClass()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

returns the hash code value for the object

A

int hashCode()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

wakes a single thread that is waiting on this object’s monitor

A

void notify()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

wakes all threads that are waiting on this object’s monitor

A

void notifyAll()

17
Q

Returns a string representation of the object

A

String toString()

18
Q

causes current thread to wait until either another thread invokes notify() ot the notifyAll() method, or a specified amoint of time has passed

A

void wait(long timeout)

19
Q

causes to current thread to wait until another thread invokes notify() or notifyAll() or other thread interrupts the current thread, or a certain amount of real time has elapsed

A

void wait(long timeout, int nanos)

20
Q

Converts an Object into String, and it contains information about the Object

A

toString() method

21
Q

Output of toString() method

A
  • Class name
  • @ sign
  • Hash code
22
Q

It displays some or all data field values for object and can be very useful when debugging

A

Overloaded version of toString() method

23
Q

it returns a boolean value that indicates whether objects are equal or have the smae hash code

A

equals() method

24
Q

It returns integer representing the hash code and when equals() is overriden, it is overriden too.

25
Advantages of extendable superclasses
- Save development time - Save testing time - Programmers understand how superclass works - Superclass maintains its integrity
26
Multiple Inheritance
Inherit from more than one class, but it is prohibited in Java
27
An alternative to multiple inheritance
Interfaces
28
Characteristic of Interface
Methods are implicitly public, abstract, and final
29
Abstract Class characteristics
Abstract class cannot instantiate objects - Can contain nonabstract methods - Provide data or methods that subclasses can inherit - Subclasses maintain ability to override inherited methods -Can include methods that contain actual behavior object performs
30
Interface characteristics
- Methods must be abstract - programmer knows what actions to include - Every implementing class defines behavior that must occur when method executes - Class can implement behavior from more than one parent - public, static, final - contain constants
31
A collection of classes that easily imports related classes into new programs
Package
32
It encourages other programmer to reuse software as it helps avoid naming conflicts or collisions; has a unique name
Package
33
How to compile file to place in a package?
- javac command - import declaration
34
It compresses and store data to reduce sizes of archived class files based on ZIP file format which is delivered to users
Java ARchive File (JAR)