Top Interview Questions for Web Developers

1.      Write a MySQL query to find out the Second Highest salary:

ANS:

SELECT DealCode FROM (Select DealCode from deals order by DealCode Desc LIMIT 2as SAL Where 1 Order By DealCode ASC LIMIT 1

The above is the simplest form to select the second largest/highest value (salary) from the table. You can select the 3rd, 4th, and so on the highest value in the same way by just changing the limit value of the inner select.

 

2.      What is Dimond Problem?

ANS:
Suppose we have 4 classes namely class A, class B, class C and class D. We have inherited classes B and C with class A. Class D is inherited with both A and B.

Class A = Super Class

Class B = Child of A

Class C = Child of A

Class D = Child of A and B (Inherited from both B and C)

Suppose we have a function sayHello() in our super class.

We will be accessing this in Class B and C easily but, what happens when we try to access this function from class D as D is inherited from both B and C? Will it access the sayHello() function through B or C?

The above ambiguity is called Dimond Problem. Different programming languages tackle this in different ways and some are not even providing the multiple inheritances only due to the diamond problem.

 

3.      What is the difference between Cache, Cookies, and Session?

ANS:

Session:
Session stores the current web browser information, which hit the server, on the server like ( in the database, in the file storage system, etc).

Cookies:
Cookies are small files stored on the client browser sent by the server in Http header response. This is because Http is stateless and whenever the client requests to the server, the server gets the cookies from the client’s request header to identify the user.

Cache:
The cache is a storage system on the client computer used to store text files, images, HTML files, etc. Static resources are usually stored in caches to improve the load time of the application. It doesn’t need to re-fetch again the resources from the server every time if they already exist in the cache. This helps a lot to improve the performance as well as decrease the unnecessary load on the server.

 

4.     What are the building blocks of OOPs

Ans:

  • Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism

 

5.     What is the difference between sessionStorage and localStorage

ANS

Both sessionStorage and localStorage are browser-based and domain-specific storage system. Setting and getting the data in both the option is the same, the only difference is that sessionStorage will be deleted when you closed the browser and the localStorage will always be there until you manually delete this.

 

6.     Explain Services in Angular?

Angular services are singleton objects that get instantiated only once during the lifetime of an application. Data does not get refreshed and is available all the time. Organize and share the business logic, models,  data and functions with different components of an app is the core objective of the services in angular application.

 

7.     What is a trait in PHP?
Ans: Laravel 5.4 introduced a mechanism to overcome the single inheritance which enables developers to reuse the set of methods in several independent classes living in different class hierarchies. That method is called a trait.

interview question developer website php
A
@ 03/10/2020
© All right reserved 2026