OOP Flashcards

(23 cards)

1
Q

Define a class

A

A blueprint for creating objects; groups fields & methods.

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

Define an object

A

An instance of a class.

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

Define a method

A

Subprogram/code that performs a single task.

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

Give examples of access modifiers.

A

Private, public, protected.

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

Define a constructor

A

A special method that assigns values to object fields when created.

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

Define method overloading

A

Having multiple methods with the same name but different parameter lists in the same class.

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

Define method overriding

A

Subclass redefines a method from the superclass (same name, same parameters).

Method overriding in Java occurs when a subclass provides a specific implementation for a method that is already defined in its superclass

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

Define encapsulation

A

Combining attributes and behaviors into a single unit (one class)

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

Explain the reliability of encapsulation

A
  • Promotes information hiding, where internal details of the class are not directly accessibly from the outside class
  • Prevents external code from modifying the internal state of an object
  • . By encapsulating the internal details, you have more control over the class, making it less prone to unintended misuse
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define an accessor method.

A

A typed method that returns a value from an object.

A method that gets (returns) a field’s value.

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

What does an access modifier do?

A

Controls visibility of class, method, or variable.

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

Define a mutator method.

A

A method that changes object fields but does not return a value.

A method that sets or changes a field’s value.

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

What is the purpose of encapsulation?

A

Protect data by hiding it and controlling access.

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

What is the advantage of OOP

A

Allows code reuse and easier program design

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

Define inheritance.

A

A class uses properties and methods from another class.

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

Define method resolution

A
  • the appropriate method will be invoked (called) based on the type of the object declared in another class
  • Ability of the programming language / java to determine which
    method to called based on the method signature
17
Q

Define a method signature.

A

The method name + number and types of parameters.

18
Q

Define a superclass.

A

The parent class in an inheritance hierarchy.

19
Q

Define a subclass.

A

A child class that inherits from a parent class.

20
Q

What is a typed method versus a void method?

A

A typed method returns a value.

A void method does not return any value.

21
Q

What is the difference between static and non static

A

Static Method - A method that belongs to the entire class instead of one instance of the class.

  • Static fields and methods belong to a CLASS.
  • Non-static fields and methods belong to an OBJECT
22
Q

Explain why constants are useful in programming

A
  • Constants are useful in programming when a value needs to remain fixed
    throughout the program’s execution.
  • They provide a way to give meaningful names
    to fixed values, making the code more readable and maintainable.
  • Constants also
    make it easier to update a value in a single place in the code.
23
Q

Define polymorphism

A
  • One method behaving differently based on the object or parameters.
  • allows objects of different classes to be treated as objects of a common superclass. This enables a single action to be performed in different ways, based on the specific object being used