SWE Interview - Set 5 Flashcards

1
Q

Describe an example of Polymophism using:

  • Animal Class
  • Dog Class
  • Cat Class
  • Method: makeSound()
A

Animal class has makeSound(); Dog and Cat extend Animal, overriding makeSound() with specific sounds, allowing polymorphic use of makeSound(). Despite declaring an instance of dog and cat as Animal type, they can hold instances of Dogand Cat, respectively.

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

What is an example of a connascent code? (with Spring boot app in mind.)

A

A UserService relies on the UserRepository interface rather than a concrete implementation. This reduces connascence because UserService isn’t tightly coupled to a specific implementation of the repository, promoting flexibility and easier maintenance.

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

What is Low coupling?

A

Low coupling signifies that modules are relatively independent of each other.

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

What is a fundamental principle in software design to promote more flexible, maintainable, and scalable systems?

A

Aiming for low coupling and high cohesion for more flexible, maintainable, and scalable systems.

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

What design principles aid in reducing direct dependencies between modules to achieve low coupling in software development?

A

Dependency Injection, Interfaces, and Abstraction facilitate the creation of modules interacting through well-defined interfaces, reducing direct dependencies and promoting flexibility.

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

What are the types of polymorphism?

A
  • Runtime Polymorphism
  • Compile Time Polymorphism
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Operator overloading

A

Operator overloading refers to the ability to define multiple behaviors for a specific operator based on the context of its operands. It allows customizing how operators like +, -, *, etc., work with user-defined objects, enhancing code clarity and flexibility by enabling intuitive operations on custom types.Not supported in Java

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

What is Function/Method overloading? Describe an example.

A

When multiple functions with the same name but different parameters are defined in a class. The appropriate function is chosen during the compile time based on the arguments provided.An example of Compile-Time Polymorphism

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

What are other design patterns of IoC?

A
  • Service Locator Pattern
  • Factory Pattern
  • Event-based IoC
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Polymorphism

A

Ability to present one interface for multiple data types, allowing objects of different classes to be treated as objects of a common superclass.

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

Inheritance

A

Mechanism where a new class inherits properties and behavior from an existing class, fostering code reuse and establishing a hierarchical relationship.

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

Encapsulation

A

Concept of bundling data and methods within a class, restricting access to the internal state of an object and promoting data integrity.

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