MOOC Part 9 Flashcards

1
Q

Why does every class in java have the built in methods methods toString, equals, and hashCode?

A

Every java class inherits the Object class.

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

What is the concept of polymorphism?

A

The capability of a method to do different things based on the object that it is acting upon. In other words, polymorphism allows you define one interface and have multiple implementations.

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

What are the two types of polymorphism?

A

Compile time which uses method overloading, functions can be overloaded by the change in the number of arguments.

Run time uses method overriding, in which the subclass provides a definition to a method already present in the superclass, then that function in the base class is overridden.

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

What is the concept of inheritance?

A

A process in which one class (subclass) acquires the properties (methods and fields) of another class (superclass).

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

What keyword is used to to inherit the properties of a class?

A

extends

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

What is the protected access modifier?

A

Open to use by its subclasses and the class it was defined in

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

What is the Single Responsibility Principle?

A

Each class should only have one responsibility, thus one reason to change. It reduces the probability and complexity of class changes as it reduces the number of dependent classes affect by changes.

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

What is an interface and its purpose?

A

A container that stores the specification of method protoypes, allows the specification of methods and fields through only names, parameters and return values, does not have a say on the internal implementation. Also allows for multiple inheritence.

Futhermore, it reducing dependacies between classes.

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