OO Theory Flashcards

OO Concepts like race conditions, async vs wait, thread vs processes, and etc.

1
Q

What is polymorphism?

A
Method overloading (static)
Method overriding (dynamic) - enables the developer of the subclass to customize or completely replace the behavior of that method.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between an interface and an abstract method?

A

An interface is a contract: The person writing the interface says, “hey, I accept things looking that way”, and the person using the interface says “OK, the class I write looks that way”.

An interface is an empty shell. There are only the signatures of the methods, which implies that the methods do not have a body. The interface can’t do anything. It’s just a pattern.

  1. Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
  2. Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
  3. Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
  4. An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
  5. A Java class can implement multiple interfaces but it can extend only one abstract class.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is a Hash Table typically implemented?

A

It uses a hash function to compute an index into an array in which an element will be inserted or searched.

Hashing is the transformation of a string of characters into a usually shorter fixed-length value or key that represents the original string. Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value.

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

What are main features of OOP?

A

Encapsulation
Polymorphism
Inheritance

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

Why OOP?

A

The main advantage of OOP is better manageable code that covers following.

1) The overall understanding of the software is increased as the distance between the language spoken by developers and that spoken by users.
2) Object orientation eases maintenance by the use of encapsulation.

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

What is encapsulation?

A

1) Data hiding: A language feature to restrict access to members of an object. For example, private and protected members in C++.
2) Bundling of data and methods together: Data and methods that operate on that data are bundled together.

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

What is abstraction?

A

Its main goal is to handle complexity by hiding unnecessary details from the user. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity.

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