Object-oriented programming (OOP Flashcards

1
Q

What is a class?

A

A blueprint describing objects, and can be instantiated using a constructor to create an object

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

What is an object?

A

An object is an instance of a class

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

What does it mean to instantiate?

A

Create a new object

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

What is a method?

A

A piece of code that can be called by name, describes what the code in it can perform

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

What is a static method?

A

A method that belongs to the class, not specific to an object. Can be instantiated without creating an object of class

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

What is a constructor?

A

A special method that can create an object.

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

Superclass/base class

A

The class from which subclasses are derived. All classes are derived from Object class in Java

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

What’s a subclass?

A

A class that derives instance variables from a class

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

What is encapsulation?

A

making variables that can only be seen within a class. Public methods (like Getters and setters) are used to view the values of the variables.

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

What is polymorphism?

A

Subclasses can share traits with its parent class. Methods can have the same name but have different functionalities. Useful for when you want the method to perform different actions depending on parameters

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

What is overriding?

A

Overrides are created in a subclass with the same method name, but have different functionalities

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

What is an interface?

A

An interface provides the functionalities that a class must have. Good for making sure that classes have necessary methods

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

What is an abstract class?

A

A class that can’t be instantiated. and made for other classes to extend. Defines templates for other classes, and what functionalities they should have. Different from interfaces in that they can also define behavior.

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

What is extending vs implementing?

A

When extending, you want to use the functionalities of the class. When implementing, you just want to make sure that certain features are implemented

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

Private vs public vs protected

A

Private methods can only be seen within the class the variable is created in. Public can be accessed globally, and protected can only be seen by the package, subclass, and the class it’s in.

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

is-a vs has-a

A

is-a is based on inheritance.