Interview questions 2 Flashcards

1
Q

What is a data structure?

A

A storage format that defines the way data is stored, organized, and manipulated.

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

What is an array?

A

Collection of items of the same type in contiguous memory locations.

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

What is a linked list?

A

A linear data structure in which elements are not necessarily stored contiguously. Sequence of nodes, each one pointing to the next in a chain-like structure.

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

What is a binary tree?

A

An extension of the linked list where each node has at most 2 children.

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

What is recursion?

A

A function calling itself based on a terminating condition.

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

What is OOP?

A

A paradigm that provides concepts such as objects, classes, and inheritance.

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

What is an object in OOP?

A

A real-world entity that has a particular state and behavior. It is an instance of a class.

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

What is a class in OOP?

A

A logical entity that defines the blueprint from which an object can be created or instantiated.

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

What is inheritance & its benefits?

A

An object gaining all the properties & behaviors of a parent object. Provides code reusability.

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

What is polymorphism?

A

A concept that allows a variable, function, or object to take on multiple forms. This happens when many classes are related to each other by inheritance.

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

Inheritance vs polymorphism.

A

While inheritance allows us to inherit attributes & methods from another class, polymorphism uses those methods to perform different tasks.

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

Example of polymorphism.

A

class Animal
public void animalSound()
System.out.println(“The animal makes a sound”);

class Pig extends Animal
public void animalSound() {
System.out.println(“The pig says: wee wee”);

class Dog extends Animal
public void animalSound() {
System.out.println(“The dog says: bow wow”);

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

What is overloading?

A

Method Overloading allows different methods to have the same name, but different signatures where the signature can differ by the number of input parameters or type of input parameters, or a mixture of both.

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

What is overriding?

A

Same method (with same parameters & type) exists in a child & parent class. The child is given priority.

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

What is an abstract class?

A

A class you cannot instantiate.

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

What is an interface?

A

Specifies the behavior of a class.

17
Q

What is a DLL?

A

Special type of LL in which traversal across the data elements can be done in both directions. 2 links per node - one that goes to the next node and one to the node before it.

18
Q

What is a deque?

A

Double-ended queue. Elements can be inserted or removed from either end.

19
Q

How does variable declaration affect memory?

A

The amount of memory that will be reserved or allocated depends on the data type being stored in that variable.

20
Q

What are dynamic data structures?

A

Expand & contract as a program runs. Provides very flexible method of data manipulation.

21
Q

What is cohesion vs coupling?

A

Coupling describes the relationships between modules, and cohesion describes the relationships within them.

22
Q

Benefits of cohesion.

A

Increased module reusability

23
Q

When method overloading exists, does the parent or child get higher priority?

A

Child

24
Q

Purpose of an abstract class.

A

To create a template for future classes. Abstract classes/methods are generally used when a class provides some high level functionality but leaves out certain details to be implemented by derived classes.

25
Q

What does it mean for a class to implement an interface.

A

When a class implements an interface, it is agreeing to perform the specific behaviors of the interface.

26
Q

What does it mean to extend an interface.

A

The child interface inherits the methods of the parent interface.

27
Q

What properties does an interface have (vs a class)?

A

Cannot be instantiated, has no constructors, all its methods are abstract, all fields must be declared static & final.

28
Q

What does an interface do, allow, and why is it beneficial?

A

Increases abstraction by specifying only the method signature and not its implementation. Also allows for multiple inheritance. Last, while using an interface, we define the method separately and the signature separately. This way, all the methods, and classes are entirely independent and archives Loose Coupling.