1. What is object-oriented programming (OOP)?
Answer:
OOP is a programming paradigm that uses objects and classes to organize code. The four key principles are:
- Encapsulation: Bundling of data with the methods that operate on that data.
- Inheritance: The ability to create new classes from existing ones.
- Polymorphism: The ability to present the same interface for different types.
- Abstraction: Hiding the implementation details and showing only functionality.
2. What is a design pattern?
Answer:
A design pattern is a general repeatable solution to a commonly occurring problem in software design. Examples include Singleton, Factory, Observer, and Decorator patterns.
3. What is the difference between abstract class and interface in Java/C#?
Answer:
- Abstract Class: Can have both abstract methods (no implementation) and concrete methods. Allows fields and constructors.
- Interface: Can only have abstract methods (before Java 8) and static/final variables. Starting from Java 8, interfaces can also have default methods.
4. What are the SOLID principles?
Answer:
SOLID is an acronym for five principles of object-oriented design:
- Single Responsibility Principle.
- Open/Closed Principle.
- Liskov Substitution Principle.
- Interface Segregation Principle.
- Dependency Inversion Principle.
5. What is a REST API?
Answer:
REST (Representational State Transfer) is an architectural style for creating web services. It relies on stateless, client-server, cacheable communications protocols—most commonly, HTTP.
6. What is a microservice architecture?
Answer:
Microservice architecture is a style of developing software systems where a large application is divided into smaller, independent services that communicate over a network, often using HTTP APIs or message queues.
7. What is the difference between SQL and NoSQL databases?
Answer:
- SQL: Relational databases with structured query language (e.g., MySQL, PostgreSQL). Data is stored in tables with fixed schemas.
- NoSQL: Non-relational databases (e.g., MongoDB, Cassandra) where data is stored in formats like key-value pairs, documents, or graphs, and schemas are flexible.
8. What is a race condition?
Answer:
A race condition occurs when two or more threads or processes access shared data and try to change it at the same time, leading to unpredictable results.
9. What is continuous integration (CI)?
Answer:
Continuous Integration is a software development practice where developers regularly merge their code changes into a shared repository, which triggers automated builds and tests to ensure code quality.
10. What is the difference between Git and SVN?
Answer:
- Git: A distributed version control system where each user has a complete local repository.
- SVN (Subversion): A centralized version control system where there is one central repository that users check out and commit changes to.
11. Explain MVC architecture.
Answer:
MVC stands for Model-View-Controller:
- Model: Manages the data and logic of the application.
- View: Represents the UI elements and presentation layer.
- Controller: Handles the user input and interaction, updating the model or view accordingly.
12. What is a deadlock in multithreading?
Answer:
A deadlock occurs when two or more threads are blocked forever, each waiting for the other to release a lock on a shared resource.
13. What is garbage collection in programming?
Answer:
Garbage collection is the automatic process of deallocating memory by removing objects that are no longer in use by the program, helping to manage memory efficiently.
14. What are the differences between Agile and Waterfall methodologies?
Answer:
- Waterfall: A linear, sequential approach where each phase depends on the completion of the previous one.
- Agile: An iterative approach where development is broken into small cycles (sprints), allowing for continuous feedback and adaptation.
15. What is the difference between a process and a thread?
Answer:
- Process: A standalone program in execution with its own memory space.
- Thread: A smaller unit of execution within a process that shares the process’s memory space.
16. What is SQL injection, and how can you prevent it?
Answer:
SQL injection is a code injection technique where an attacker inserts malicious SQL statements into a query to manipulate a database. It can be prevented by using parameterized queries or prepared statements.
17. What is version control, and why is it important?
Answer:
Version control systems (VCS) like Git track changes to code over time, allowing multiple developers to collaborate, manage different versions of software, and revert to previous states if needed.
18. What is a virtual function in C++?
Answer:
A virtual function is a function declared in the base class that can be overridden in derived classes. It allows dynamic binding and polymorphism, ensuring that the correct function is called for an object, regardless of its reference type.
19. What is big-O notation?
Answer:
Big-O notation is a mathematical representation of an algorithm’s time or space complexity, describing the worst-case scenario in terms of input size. For example, O(n), O(log n), O(n^2).
20. What is the difference between '==' and 'equals()' in Java?
Answer:
- '==': Compares object references to check if two variables point to the same object.
- equals(): Compares the values of the objects to check if they are logically equivalent.