Intermediate Interview Questions
S - Single Responsibility Principle (SRP): The single responsibility principle ensures that every class or module should be accountable and responsible for only one functionality. There should be one and only one reason for changing any class.
O - Open Closed Principle (OCP): Every class is open for extension but closed for modification. Here, we are allowed to extend the entities behaviour by not modifying anything in the existing source code.
L - Liskov Substitution Principle(LSP): LSP principle states that the objects can be replaced by the subtype instances without affecting the correctness of the program.
I - Interface Segregation Principle (ISP): The ISP principle states that we can use as many interfaces specific to the client’s requirements instead of creating only one general interface. Clients should not be forced to implement the functionalities that they do not require.
D - Dependency Inversion Principle: Here, the high-level modules should not be dependent on the lower level modules or concrete implementations. Instead, they should be dependent on the abstractions.
You can register services, events, etc., using a service provider before booting the application.
They help inject Laravel services or your application services and dependencies.
Laravel supports four database systems:
1- MySQL.
2- Postgres.
3- SQLite.
4- SQL Server.
Laravel Events and Listeners provide a simple and convenient way to implement event-driven programming in your application. Events are triggered when certain actions occur, and listeners are responsible for handling those events and executing the necessary code in response.
Dependency injection and class dependency management are made easier with the help of the Laravel Service Container.
It allows you to bind classes into the container, resolve dependencies automatically, and inject them into your classes when needed.
- MyISAM is a storage engine in MySQL known for its simplicity and speed, but lacks support for transactions and foreign keys.
- InnoDB, on the other hand, is a more robust storage engine that supports transactions, foreign keys, and row-level locking, making it suitable for mission-critical applications.
1- Flexibility: MySQL runs on all operating systems
2- Power: MySQL focuses on performance
3- Enterprise-Level SQL Features: MySQL had for some time been lacking in advanced features such as subqueries, views, and stored procedures.
4- Full-Text Indexing and Searching
5- Query Caching: This helps enhance the speed of MySQL greatly
6- Replication: One MySQL server can be duplicated on another, providing numerous advantages
7- Configuration and Security
There are several storage engines in MySQL, and the table types depend on which storage engine is used. The common storage engines are:
1- InnoDB (default in MySQL for transactional data)
2- MyISAM (older, non-transactional storage engine)
3- MEMORY (stores data in memory)
4- CSV (stores data in CSV files)
5- ARCHIVE (used for storing large amounts of data, read-only)
They are a set of syntax used in SQL that have a specific job, but they have a little different
- Function: Must return a value and accept parameters only, like ( max(), min(), rand(), upper(), lower() ).
- Stored Procedures: It's optional to return a value or accept parameters, like ( rename, change, help ).
Abstraction is similar to data encapsulation and is very important in OOP.
It means showing only the necessary information and hiding the other irrelevant information from the user.
Abstraction is implemented using classes and interfaces.
The base class is the root class- the most generalized class. At the same time,
The superclass is the immediate parent class from which the other class inherits.
Encapsulation is the process of binding data members and methods of a program together to do a specific job, without revealing unnecessary details.
Encapsulation can also be defined in two different ways:
1) Data hiding: Encapsulation is the process of hiding unwanted information, such as restricting access to any member of an object.
2) Data binding: Encapsulation is the process of binding the data members and the methods together as a whole, as a class.
Access specifiers are special types of keywords that are used to specify or control the accessibility of entities like classes, methods, and so on.
Private, Public, and Protected are examples of access specifiers or access modifiers, also known as visibility markers.
Inheritance is relationship between two or more classes where derived class inherits properties of pre-existing (class).
The idea of inheritance is simple, a class is derived from another class and uses data and implementation of that other class. The class which is derived is called child or derived or subclass and the class from which the child class is derived is called parent or base or superclass.
The main purpose of Inheritance is to increase code reusability. It is also used to achieve Runtime Polymorphism.
If one class shares the behavior and structure defined in another multiple class, it is called multiple inheritance.
An interface refers to a special type of class, which contains methods, but not their definition. Only the declaration of methods is allowed inside an interface. To use an interface, you cannot create objects. Instead, you need to implement that interface and define the methods for their implementation.
Superclass is also a part of Inheritance. The superclass is an entity, which allows subclasses or child classes to inherit from itself.
It is also known as the parent class or base class.
The subclass is a part of Inheritance. The subclass is an entity, which inherits from another class. It is also known as the child class or delivered class.
An object refers to the instance of the class, which contains the instance of the members and behaviors defined in the class template. In the real world, an object is an actual entity to which a user interacts, whereas class is just the blueprint for that object. So the objects consume space and have some characteristic behavior.
For example, a specific car (bmw, ford, etc...).
A class can be understood as a template or a blueprint, which contains some values, known as member data or member, and some set of rules, known as behaviors or functions. So when an object is created, it automatically takes the data and functions that are defined in the class.
Therefore the class is basically a template or blueprint for objects. Also one can create as many objects as they want based on a class.
For example, first, a car’s template is created. Then multiple units of cars are created based on that template.
The main feature of the OOPs, also known as 4 pillars or basic principles of OOPs are as follows:
1- Encapsulation
2- Data Abstraction
3- Polymorphism
4- Inheritance
The programming languages that use and follow the Object-Oriented Programming paradigm or OOPs, are known as Object-Oriented Programming languages. Some of the major Object-Oriented Programming languages include:
- C++
- C#
- Java
- Javascript
- Python
- PHP
And many more.
The main advantage of OOP is better-managed code that covers the following:
1- The overall understanding of the software is increased as the distance between the language spoken by developers and that spoken by users.
2- Object orientation eases maintenance by the use of encapsulation. One can easily change the underlying representation by keeping the methods the same.
3- The OOPs paradigm is mainly useful for relatively big software.
4- OOPs helps users to understand the software easily, although they don’t know the actual implementation.
5- With OOPs, the readability, understandability, and maintainability of the code increase multifold.
6- Even very big software can be easily written and managed easily using OOPs.