aershov24 / front-end-developer-interview-questions

Awesome list of front end developer interview questions from FullStack.Cafe

Home Page:https://www.fullstack.cafe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Originally published on 👉 11 Painful Git Interview Questions You Will Cry On | FullStack.Cafe

Q1: What is Git fork? What is difference between fork, branch and clone? ⭐⭐

Answer:

  • A fork is a remote, server-side copy of a repository, distinct from the original. A fork isn't a Git concept really, it's more a political/social idea.
  • A clone is not a fork; a clone is a local copy of some remote repository. When you clone, you are actually copying the entire source repository, including all the history and branches.
  • A branch is a mechanism to handle the changes within a single repository in order to eventually merge them with the rest of code. A branch is something that is within a repository. Conceptually, it represents a thread of development.

Source: stackoverflow.com

Q2: What is the difference between "git pull" and "git fetch"? ⭐⭐

Answer: In the simplest terms, git pull does a git fetch followed by a git merge.

  • When you use pull, Git tries to automatically do your work for you. It is context sensitive, so Git will merge any pulled commits into the branch you are currently working in. pull automatically merges the commits without letting you review them first. If you don’t closely manage your branches, you may run into frequent conflicts.

  • When you fetch, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repository. However, it does not merge them with your current branch. This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use merge.

Source: stackoverflow.com

Q3: What's the difference between a "pull request" and a "branch"? ⭐⭐

Answer:

  • A branch is just a separate version of the code.

  • A pull request is when someone take the repository, makes their own branch, does some changes, then tries to merge that branch in (put their changes in the other person's code repository).

Source: stackoverflow.com

Q4: How to revert previous commit in git? ⭐⭐⭐

Answer: Say you have this, where C is your HEAD and (F) is the state of your files.

   (F)
A-B-C
    ↑
  master
  1. To nuke changes in the commit:
git reset --hard HEAD~1

Now B is the HEAD. Because you used --hard, your files are reset to their state at commit B. 2. To undo the commit but keep your changes:

git reset HEAD~1

Now we tell Git to move the HEAD pointer back one commit (B) and leave the files as they are and git status shows the changes you had checked into C. 3. To undo your commit but leave your files and your index

git reset --soft HEAD~1

When you do git status, you'll see that the same files are in the index as before.

Source: stackoverflow.com

Q5: What is "git cherry-pick"? ⭐⭐⭐

Answer: The command git cherry-pick is typically used to introduce particular commits from one branch within a repository onto a different branch. A common use is to forward- or back-port commits from a maintenance branch to a development branch.

This is in contrast with other ways such as merge and rebase which normally apply many commits onto another branch.

Consider:

git cherry-pick <commit-hash>

Source: stackoverflow.com

Q6: Explain the advantages of Forking Workflow ⭐⭐⭐

Answer: The Forking Workflow is fundamentally different than other popular Git workflows. Instead of using a single server-side repository to act as the “central” codebase, it gives every developer their own server-side repository. The Forking Workflow is most often seen in public open source projects.

The main advantage of the Forking Workflow is that contributions can be integrated without the need for everybody to push to a single central repository that leads to a clean project history. Developers push to their own server-side repositories, and only the project maintainer can push to the official repository.

When developers are ready to publish a local commit, they push the commit to their own public repository—not the official one. Then, they file a pull request with the main repository, which lets the project maintainer know that an update is ready to be integrated.

Source: atlassian.com

Q7: Tell me the difference between HEAD, working tree and index, in Git? ⭐⭐⭐

Answer:

  • The working tree/working directory/workspace is the directory tree of (source) files that you see and edit.
  • The index/staging area is a single, large, binary file in /.git/index, which lists all files in the current branch, their sha1 checksums, time stamps and the file name - it is not another directory with a copy of files in it.
  • HEAD is a reference to the last commit in the currently checked-out branch.

Source: stackoverflow.com

Q8: Could you explain the Gitflow workflow? ⭐⭐⭐

Answer: Gitflow workflow employs two parallel long-running branches to record the history of the project, master and develop:

  • Master - is always ready to be released on LIVE, with everything fully tested and approved (production-ready).

  • Hotfix - Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a lot like release branches and feature branches except they're based on master instead of develop.

  • Develop - is the branch to which all feature branches are merged and where all tests are performed. Only when everything’s been thoroughly checked and fixed it can be merged to the master.

  • Feature - Each new feature should reside in its own branch, which can be pushed to the develop branch as their parent one.

Source: atlassian.com

Q9: When should I use "git stash"? ⭐⭐⭐

Answer: The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy.

Consider:

$ git status
On branch master
Changes to be committed:
new file: style.css
Changes not staged for commit:
modified: index.html
$ git stash
Saved working directory and index state WIP on master: 5002d47 our new homepage
HEAD is now at 5002d47 our new homepage
$ git status
On branch master
nothing to commit, working tree clean

The one place we could use stashing is if we discover we forgot something in our last commit and have already started working on the next one in the same branch:

# Assume the latest commit was already done
# start working on the next patch, and discovered I was missing something

# stash away the current mess I made
$ git stash save

# some changes in the working dir

# and now add them to the last commit:
$ git add -u
$ git commit --ammend

# back to work!
$ git stash pop

Source: atlassian.com

Q10: How to remove a file from git without removing it from your file system? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: When do you use "git rebase" instead of "git merge"? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 112+ Behavioral Interview Questions for Software Developers | FullStack.Cafe

Q1: How do you spend your time outside work? ⭐

Answer:

Originally published on 👉 13 Tricky CSS3 Interview Questions And Answers to Stand Out on Interview in 2018 | FullStack.Cafe

Q1: Describe floats and how they work ⭐⭐

Answer: Float is a CSS positioning property. Floated elements remain a part of the flow of the web page. This is distinctly different than page elements that use absolute positioning. Absolutely positioned page elements are removed from the flow of the webpage.

#sidebar {
  float: right; // left right none inherit			
}

The CSS clear property can be used to be positioned below left/right/both floated elements.

Source: css-tricks.com

Q2: How is responsive design different from adaptive design? ⭐⭐⭐

Answer: Both responsive and adaptive design attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage contexts, control mechanisms, and so on.

Responsive design works on the principle of flexibility — a single fluid website that can look good on any device. Responsive websites use media queries, flexible grids, and responsive images to create a user experience that flexes and changes based on a multitude of factors. Like a single ball growing or shrinking to fit through several different hoops.

Adaptive design is more like the modern definition of progressive enhancement. Instead of one flexible design, adaptive design detects the device and other features, and then provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics. The site detects the type of device used, and delivers the pre-set layout for that device. Instead of a single ball going through several different-sized hoops, you’d have several different balls to use depending on the hoop size.

Source: codeburst.io

Q3: How does CSS actually work (under the hood of browser)? ⭐⭐⭐

Answer: When a browser displays a document, it must combine the document's content with its style information. It processes the document in two stages:

  • The browser converts HTML and CSS into the DOM (Document Object Model). The DOM represents the document in the computer's memory. It combines the document's content with its style.
  • The browser displays the contents of the DOM.

Source: developer.mozilla.org

Q4: What does Accessibility (a11y) mean? ⭐⭐⭐

Answer: Accessibility (a11y) is a measure of a computer system's accessibility is to all people, including those with disabilities or impairments. It concerns both software and hardware and how they are configured in order to enable a disabled or impaired person to use that computer system successfully.

Accessibility is also known as assistive technology.

Source: techopedia.com

Q5: Explain the purpose of clearing floats in CSS ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q6: How do you optimize your webpages for print? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q7: Can you explain the difference between coding a website to be responsive versus using a mobile-first strategy? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q8: Explain the basic rules of CSS Specificity ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q9: Is there any reason you'd want to use translate() instead of absolute positioning, or vice-versa? And why? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q10: What the code fragment has the greater CSS specificity? ⭐⭐⭐⭐

Details:

Consider the three code fragments:

// A
h1
// B 
#content h1
// C 
<div id="content">
   <h1 style="color: #fff">Headline</h1>
</div>

What the code fragment has the greater specificy?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: What clearfix methods do you know? Provide some examples. ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: How to style every element which has an adjacent item right before it? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: Write down a selector that will match any links end in .zip, .ZIP, .Zip etc... ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 15 ASP.NET Web API Interview Questions And Answers (2019 Update) | FullStack.Cafe

Q1: What is ASP.NET Web API? ⭐

Answer: ASP.NET Web API is a framework that simplifies building HTTP services for broader range of clients (including browsers as well as mobile devices) on top of .NET Framework.

Using ASP.NET Web API, we can create non-SOAP based services like plain XML or JSON strings, etc. with many other advantages including:

  • Create resource-oriented services using the full features of HTTP
  • Exposing services to a variety of clients easily like browsers or mobile devices, etc.

Source: codeproject.com

Q2: What are the Advantages of Using ASP.NET Web API? ⭐⭐

Answer: Using ASP.NET Web API has a number of advantages, but core of the advantages are:

  • It works the HTTP way using standard HTTP verbs like GET, POST, PUT, DELETE, etc. for all CRUD operations
  • Complete support for routing
  • Response generated in JSON or XML format using MediaTypeFormatter
  • It has the ability to be hosted in IIS as well as self-host outside of IIS
  • Supports Model binding and Validation
  • Support for OData

Source: codeproject.com

Q3: Which status code used for all uncaught exceptions by default? ⭐⭐

Answer: 500 – Internal Server Error

Consider:

[Route("CheckId/{id}")]
[HttpGet]
public IHttpActionResult CheckId(int id)
{
    if(id > 100)
    {
        throw new ArgumentOutOfRangeException();
    }
    return Ok(id);
}

And the result:

Source: docs.microsoft.com

Q4: What is the difference between ApiController and Controller? ⭐⭐

Answer:

  • Use Controller to render your normal views.
  • ApiController action only return data that is serialized and sent to the client.

Consider:

public class TweetsController : Controller {
  // GET: /Tweets/
  [HttpGet]
  public ActionResult Index() {
    return Json(Twitter.GetTweets(), JsonRequestBehavior.AllowGet);
  }
}

or

public class TweetsController : ApiController {
  // GET: /Api/Tweets/
  public List<Tweet> Get() {
    return Twitter.GetTweets();
  }
}

Source: stackoverflow.com

Q5: Name types of Action Results in Web API 2 ⭐⭐⭐

Answer: A Web API controller action can return any of the following:

  • void - Return empty 204 (No Content)
  • HttpResponseMessage - Return empty 204 (No Content)
  • IHttpActionResult - Call ExecuteAsync to create an HttpResponseMessage, then convert to an HTTP response message
  • Some other type - Write the serialized return value into the response body; return 200 (OK).

Source: medium.com

Q6: Compare WCF vs ASP.NET Web API? ⭐⭐⭐

Answer:

  • Windows Communication Foundation is designed to exchange standard SOAP-based messages using variety of transport protocols like HTTP, TCP, NamedPipes or MSMQ, etc.
  • On the other hand, ASP.NET API is a framework for building non-SOAP based services over HTTP only.

Source: codeproject.com

Q7: Explain the difference between MVC vs ASP.NET Web API ⭐⭐⭐

Answer:

  • The purpose of Web API framework is to generate HTTP services that reach more clients by generating data in raw format, for example, plain XML or JSON string. So, ASP.NET Web API creates simple HTTP services that renders raw data.
  • On the other hand, ASP.NET MVC framework is used to develop web applications that generate Views (HTML) as well as data. ASP.NET MVC facilitates in rendering HTML easy.

Source: codeproject.com

Q8: What is Attribute Routing in ASP.NET Web API 2.0? ⭐⭐⭐

Answer: ASP.NET Web API v2 now support Attribute Routing along with convention-based approach. In convention-based routes, the route templates are already defined as follows:

Config.Routes.MapHttpRoute(
  name: "DefaultApi",
  routeTemplate: "api/{Controller}/{id}",
  defaults: new { id = RouteParameter.Optional }
);

So, any incoming request is matched against already defined routeTemplate and further routed to matched controller action. But it’s really hard to support certain URI patterns using conventional routing approach like nested routes on same controller. For example, authors have books or customers have orders, students have courses etc.

Such patterns can be defined using attribute routing i.e. adding an attribute to controller action as follows:

[Route("books/{bookId}/authors")]
public IEnumerable<Author> GetAuthorsByBook(int bookId) { ..... }

Source: webdevelopmenthelp.net

Q9: How to Return View from ASP.NET Web API Method? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q10: Explain briefly CORS(Cross-Origin Resource Sharing)? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: What's the difference between OpenID and OAuth? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: Why should I use IHttpActionResult instead of HttpResponseMessage? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: Explain briefly OWIN (Open Web Interface for .NET) Self Hosting? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: Could you clarify what is the best practice with Web API error management? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: What is difference between WCF and Web API and WCF REST and Web Service? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 15 Amazon Web Services Interview Questions and Answers for 2018 | FullStack.Cafe

Q1: Explain the key components of AWS? ⭐

Answer:

  • Simple Storage Service (S3): S3 is most widely used AWS storage web service.
  • Simple E-mail Service (SES): SES is a hosted transactional email service and allows one to fluently send deliverable emails using a RESTFUL API call or through a regular SMTP.
  • Identity and Access Management (IAM): IAM provides improved identity and security management for AWS account.
  • Elastic Compute Cloud (EC2): EC2 is an AWS ecosystem central piece. It is responsible for providing on-demand and flexible computing resources with a “pay as you go” pricing model.
  • Elastic Block Store (EBS): EBS offers continuous storage solution that can be seen in instances as a regular hard drive.
  • CloudWatch: CloudWatch allows the controller to outlook and gather key metrics and also set a series of alarms to be notified if there is any trouble.

Source: whizlabs.com

Q2: Is data stored in S3 is always encrypted? ⭐⭐

Answer: By default data on S3 is not encrypted, but all you could enable server-side encryption in your object metadata when you upload your data to Amazon S3. As soon as your data reaches S3, it is encrypted and stored.

Source: aws.amazon.com

Q3: What is the connection between AMI and Instance? ⭐⭐

Answer: Many different types of instances can be launched from one AMI. The type of an instance generally regulates the hardware components of the host computer that is used for the instance. Each type of instance has distinct computing and memory efficacy.

Once an instance is launched, it casts as host and the user interaction with it is same as with any other computer but we have a completely controlled access to our instances. AWS developer interview questions may contain one or more AMI based questions, so prepare yourself for the AMI topic very well.

Source: whizlabs.com

Q4: How can I download a file from EC2? ⭐⭐

Answer: Use scp:

scp -i ec2key.pem username@ec2ip:/path/to/file .

Source: stackoverflow.com

Q5: What do you mean by AMI? What does it include? ⭐⭐

Answer: AMI stands for the term Amazon Machine Image. It’s an AWS template which provides the information (an application server, and operating system, and applications) required to perform the launch of an instance. This AMI is the copy of the AMI that is running in the cloud as a virtual server. You can launch instances from as many different AMIs as you need. AMI consists of the followings:

  • A root volume template for an existing instance
  • Launch permissions to determine which AWS accounts will get the AMI in order to launch the instances
  • Mapping for block device to calculate the total volume that will be attached to the instance at the time of launch

Source: whizlabs.com

Q6: Can we attach single EBS to multiple EC2s same time? ⭐⭐

Answer: No. After you create a volume, you can attach it to any EC2 instance in the same Availability Zone. An EBS volume can be attached to only one EC2 instance at a time, but multiple volumes can be attached to a single instance.

Source: docs.aws.amazon.com

Q7: What is AWS Data Pipeline? ⭐⭐

Answer: AWS Data Pipeline is a web service that you can use to automate the movement and transformation of data. With AWS Data Pipeline, you can define data-driven workflows, so that tasks can be dependent on the successful completion of previous tasks.

Source: docs.aws.amazon.com

Q8: How many storage options are there for EC2 Instance? ⭐⭐⭐

Answer: There are four storage options for Amazon EC2 Instance:

  • Amazon EBS
  • Amazon EC2 Instance Store
  • Amazon S3
  • Adding Storage

Source: whizlabs.com

Q9: How to get the instance id from within an EC2 instance? ⭐⭐⭐

Details: How can I find out the instance id of an ec2 instance from within the ec2 instance?

Answer: Run:

wget -q -O - http://169.254.169.254/latest/meta-data/instance-id

Or on Amazon Linux AMIs you can do:

$ ec2-metadata -i
instance-id: i-1234567890abcdef0

Source: stackoverflow.com

Q10: What is the difference between Amazon EC2 and AWS Elastic Beanstalk? ⭐⭐⭐

Answer:

  • EC2 is Amazon's service that allows you to create a server (AWS calls these instances) in the AWS cloud. You pay by the hour and only what you use. You can do whatever you want with this instance as well as launch n number of instances.

  • Elastic Beanstalk is one layer of abstraction away from the EC2 layer. Elastic Beanstalk will setup an "environment" for you that can contain a number of EC2 instances, an optional database, as well as a few other AWS components such as a Elastic Load Balancer, Auto-Scaling Group, Security Group. Then Elastic Beanstalk will manage these items for you whenever you want to update your software running in AWS.

Source: stackoverflow.com

Q11: When should one use the following: Amazon EC2, Google App Engine, Microsoft Azure and Salesforce.com? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: How would you implement vertical auto scaling of EC2 instance? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: What is the underlying hypervisor for EC2? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: Our EC2 micro instance occasionally runs out of memory. Other than using a larger instance size, what else can be done? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: How to safely upgrade an Amazon EC2 instance from t1.micro to large? ⭐⭐⭐⭐⭐

Details: I have an Amazon EC2 micro instance (t1.micro). I want to upgrade this instance to large. This is our production environment, so what is the best and risk-free way to do this?

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 15 Best Continuous Integration Interview Questions (2018 Revision) | FullStack.Cafe

Q1: What is meant by Continuous Integration? ⭐

Answer: Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

Source: edureka.co

Q2: What are the success factors for Continuous Integration? ⭐⭐

Answer:

  • Maintain a code repository
  • Automate the build
  • Make the build self-testing
  • Everyone commits to the baseline every day
  • Every commit (to baseline) should be built
  • Keep the build fast
  • Test in a clone of the production environment
  • Make it easy to get the latest deliverables
  • Everyone can see the results of the latest build
  • Automate deployment

Source: edureka.co

Q3: What is the function of CI (Continuous Integration) server? ⭐⭐

Answer: CI server function is to continuously integrate all changes being made and committed to repository by different developers and check for compile errors. It needs to build code several times a day, preferably after every commit so it can detect which commit made the breakage if the breakage happens.

Source: linoxide.com

Q4: What's the difference between a blue/green deployment and a rolling deployment? ⭐⭐⭐

Answer:

  • In Blue Green Deployment, you have TWO complete environments. One is Blue environment which is running and the Green environment to which you want to upgrade. Once you swap the environment from blue to green, the traffic is directed to your new green environment. You can delete or save your old blue environment for backup until the green environment is stable.

  • In Rolling Deployment, you have only ONE complete environment. The code is deployed in the subset of instances of the same environment and moves to another subset after completion.

Source: stackoverflow.com

Q5: What is the difference between resource allocation and resource provisioning? ⭐⭐⭐

Answer:

  • Resource allocation is the process of reservation that demarcates a quantity of a resource for a tenant's use.
  • Resource provision is the process of activation of a bundle of the allocated quantity to bear the tenant's workload.

Immediately after allocation, all the quantity of a resource is available. Provision removes a quantity of a resource from the available set. De-provision returns a quantity of a resource to the available set. At any time:

Allocated quantity = Available quantity + Provisioned quantity

Source: dev.to

Q6: What are the differences between continuous integration, continuous delivery, and continuous deployment? ⭐⭐⭐

Answer:

  • Developers practicing continuous integration merge their changes back to the main branch as often as possible. By doing so, you avoid the integration hell that usually happens when people wait for release day to merge their changes into the release branch.
  • Continuous delivery is an extension of continuous integration to make sure that you can release new changes to your customers quickly in a sustainable way. This means that on top of having automated your testing, you also have automated your release process and you can deploy your application at any point of time by clicking on a button.
  • Continuous deployment goes one step further than continuous delivery. With this practice, every change that passes all stages of your production pipeline is released to your customers. There's no human intervention, and only a failed test will prevent a new change to be deployed to production.

Source: atlassian.com

Q7: Could you explain the Gitflow workflow? ⭐⭐⭐

Answer: Gitflow workflow employs two parallel long-running branches to record the history of the project, master and develop:

  • Master - is always ready to be released on LIVE, with everything fully tested and approved (production-ready).

  • Hotfix - Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a lot like release branches and feature branches except they're based on master instead of develop.

  • Develop - is the branch to which all feature branches are merged and where all tests are performed. Only when everything’s been thoroughly checked and fixed it can be merged to the master.

  • Feature - Each new feature should reside in its own branch, which can be pushed to the develop branch as their parent one.

Source: atlassian.com

Q8: Explain usage of NODE_ENV ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q9: What is LTS releases of Node.js why should you care? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q10: What Is Sticky Session Load Balancing? What Do You Mean By "Session Affinity"? ⭐⭐⭐

Answer: Sticky session or a session affinity technique is another popular load balancing technique that requires a user session to be always served by an allocated machine.

In a load balanced server application where user information is stored in session it will be required to keep the session data available to all machines. This can be avoided by always serving a particular user session request from one machine. The machine is associated with a session as soon as the session is created. All the requests in a particular session are always redirected to the associated machine. This ensures the user data is only at one machine and load is also shared.

This is typically done by using SessionId cookie. The cookie is sent to the client for the first request and every subsequent request by client must be containing that same cookie to identify the session.

** What Are The Issues With Sticky Session?**

There are few issues that you may face with this approach

  • The client browser may not support cookies, and your load balancer will not be able to identify if a request belongs to a session. This may cause strange behavior for the users who use no cookie based browsers.
  • In case one of the machine fails or goes down, the user information (served by that machine) will be lost and there will be no way to recover user session.

Source: fromdev.com

Q11: Explain Blue-Green Deployment Technique ⭐⭐⭐

Answer: Blue-green deployment is a technique that reduces downtime and risk by running two identical production environments called Blue and Green. At any time, only one of the environments is live, with the live environment serving all production traffic. For this example, Blue is currently live and Green is idle.

As you prepare a new version of your software, deployment and the final stage of testing takes place in the environment that is not live: in this example, Green. Once you have deployed and fully tested the software in Green, you switch the router so all incoming requests now go to Green instead of Blue. Green is now live, and Blue is idle.

This technique can eliminate downtime due to application deployment. In addition, blue-green deployment reduces risk: if something unexpected happens with your new version on Green, you can immediately roll back to the last version by switching back to Blue.

Source: cloudfoundry.org

Q12: Why layering your application is important? Provide some bad layering example. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: Are you familiar with The Twelve-Factor App principles? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 15 Essential HTML5 Interview Questions to Watch Out in 2018 | FullStack.Cafe

Q1: Explain meta tags in HTML ⭐

Answer:

  • Meta tags always go inside head tag of the HTML page
  • Meta tags is always passed as name/value pairs
  • Meta tags are not displayed on the page but intended for the browser
  • Meta tags can contain information about character encoding, description, title of the document etc,

Example:

<!DOCTYPE html>
<html>
<head>
  <meta name="description" content="I am a web page with description"> 
  <title>Home Page</title>
</head>
<body>
  
</body>
</html>

Source: github.com/FuelFrontend

Q2: What is an optional tag? ⭐⭐⭐

Answer: In HTML, some elements have optional tags. In fact, both the opening and closing tags of some elements may be completely removed from an HTML document, even though the elements themselves are required.

Three required HTML elements whose start and end tags are optional are the html, head, and body elements.

Source: computerhope.com

Q3: Can a web page contain multiple elements? What about elements? ⭐⭐⭐

Answer: Yes to both. The W3 documents state that the tags represent the header(<header>) and footer(<footer>) areas of their nearest ancestor "section". So not only can the page <body> contain a header and a footer, but so can every <article> and <section> element.

Source: stackoverflow.com

Q4: What is the DOM? ⭐⭐⭐

Answer: The DOM (Document Object Model) is a cross-platform API that treats HTML and XML documents as a tree structure consisting of nodes. These nodes (such as elements and text nodes) are objects that can be programmatically manipulated and any visible changes made to them are reflected live in the document. In a browser, this API is available to JavaScript where DOM nodes can be manipulated to change their styles, contents, placement in the document, or interacted with through event listeners.

  • The DOM was designed to be independent of any particular programming language, making the structural representation of the document available from a single, consistent API.
  • The DOM is constructed progressively in the browser as a page loads, which is why scripts are often placed at the bottom of a page, in the <head> with a defer attribute, or inside a DOMContentLoaded event listener. Scripts that manipulate DOM nodes should be run after the DOM has been constructed to avoid errors.
  • document.getElementById() and document.querySelector() are common functions for selecting DOM nodes.
  • Setting the innerHTML property to a new value runs the string through the HTML parser, offering an easy way to append dynamic HTML content to a node.

Source: developer.mozilla.org

Q5: Discuss the differences between an HTML specification and a browser’s implementation thereof. ⭐⭐⭐

Answer: HTML specifications such as HTML5 define a set of rules that a document must adhere to in order to be “valid” according to that specification. In addition, a specification provides instructions on how a browser must interpret and render such a document.

A browser is said to “support” a specification if it handles valid documents according to the rules of the specification. As of yet, no browser supports all aspects of the HTML5 specification (although all of the major browser support most of it), and as a result, it is necessary for the developer to confirm whether the aspect they are making use of will be supported by all of the browsers on which they hope to display their content. This is why cross-browser support continues to be a headache for developers, despite the improved specificiations.

  • HTML5 defines some rules to follow for an invalid HTML5 document (i.e., one that contains syntactical errors)
  • However, invalid documents may contain anything, so it's impossible for the specification to handle all possibilities comprehensively.
  • Thus, many decisions about how to handle malformed documents are left up to the browser.

Source: w3.org

Q6: What is HTML5 Web Storage? Explain localStorage and sessionStorage. ⭐⭐⭐

Answer: With HTML5, web pages can store data locally within the user’s browser. The data is stored in name/value pairs, and a web page can only access data stored by itself.

Differences between localStorage and sessionStorage regarding lifetime:

  • Data stored through localStorage is permanent: it does not expire and remains stored on the user’s computer until a web app deletes it or the user asks the browser to delete it.
  • sessionStorage has the same lifetime as the top-level window or browser tab in which the data got stored. When the tab is permanently closed, any data stored through sessionStorage is deleted.

Differences between localStorage and sessionStorage regarding storage scope:

Both forms of storage are scoped to the document origin so that documents with different origins will never share the stored objects.

  • sessionStorage is also scoped on a per-window basis. Two browser tabs with documents from the same origin have separate sessionStorage data.
  • Unlike in localStorage, the same scripts from the same origin can't access each other's sessionStorage when opened in different tabs.

Source: w3schools.com

Q7: What's new in HTML 5? ⭐⭐⭐

Answer: HTML 5 adds a lot of new features to the HTML specification

New Doctype

Still using that pesky, impossible-to-memorize XHTML doctype?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If so, why? Switch to the new HTML5 doctype. You'll live longer -- as Douglas Quaid might say.

<!DOCTYPE html>

New Structure

  • <section> - to define sections of pages
  • <header> - defines the header of a page
  • <footer> - defines the footer of a page
  • <nav> - defines the navigation on a page
  • <article> - defines the article or primary content on a page
  • <aside> - defines extra content like a sidebar on a page
  • <figure> - defines images that annotate an article

New Inline Elements

These inline elements define some basic concepts and keep them semantically marked up, mostly to do with time:

  • <mark> - to indicate content that is marked in some fashion
  • <time> - to indicate content that is a time or date
  • <meter> - to indicate content that is a fraction of a known range - such as disk usage
  • <progress> - to indicate the progress of a task towards completion

New Form Types

  • <input type="datetime">
  • <input type="datetime-local">
  • <input type="date">
  • <input type="month">
  • <input type="week">
  • <input type="time">
  • <input type="number">
  • <input type="range">
  • <input type="email">
  • <input type="url">

New Elements

There are a few exciting new elements in HTML 5:

  • <canvas> - an element to give you a drawing space in JavaScript on your Web pages. It can let you add images or graphs to tool tips or just create dynamic graphs on your Web pages, built on the fly.
  • <video> - add video to your Web pages with this simple tag.
  • <audio> - add sound to your Web pages with this simple tag.

No More Types for Scripts and Links

You possibly still add the type attribute to your link and script tags.

<link rel="stylesheet" href="path/to/stylesheet.css" type="text/css" />
<script type="text/javascript" src="path/to/script.js"></script>

This is no longer necessary. It's implied that both of these tags refer to stylesheets and scripts, respectively. As such, we can remove the type attribute all together.

<link rel="stylesheet" href="path/to/stylesheet.css" />
<script src="path/to/script.js"></script>

Make your content editable

The new browsers have a nifty new attribute that can be applied to elements, called contenteditable. As the name implies, this allows the user to edit any of the text contained within the element, including its children. There are a variety of uses for something like this, including an app as simple as a to-do list, which also takes advantage of local storage.

<h2> To-Do List </h2>
<ul contenteditable="true">
  <li> Break mechanical cab driver. </li>
  <li> Drive to abandoned factory
  <li> Watch video of self </li>
</ul>

Attributes

  • require to mention the form field is required
  • autofocus puts the cursor on the input field

Source: github.com/FuelFrontend

Q8: HTML Markup Validity ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q9: What are the building blocks of HTML5? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q10: What is progressive rendering? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: Why to use HTML5 semantic tags? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: What's the difference between Full Standard, Almost Standard and Quirks Mode? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: Could you generate a public key in HTML? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: What is accessibility & ARIA role means in a web application? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: What are Web Components? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 15+ Azure Interview Questions And Answers (2018 REVISIT) | FullStack.Cafe

Q1: What is Azure Cloud Service? ⭐

Answer: By creating a cloud service, you can deploy a multi-tier web application in Azure, defining multiple roles to distribute processing and allow flexible scaling of your application. A cloud service consists of one or more web roles and/or worker roles, each with its own application files and configuration. Azure Websites and Virtual Machines also enable web applications on Azure. The main advantage of cloud services is the ability to support more complex multi-tier architectures

Source: mindmajix.com

Q2: What is Azure Functions? ⭐

Answer: Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. We can write just the code we need for the problem at hand, without worrying about a whole application or the infrastructure to run it and use language of our choice such as C#, F#, Node.js, Java, or PHP. Azure Functions lets us develop serverless applications on Microsoft Azure.

Q3: What is Azure Resource Group? ⭐⭐

Answer: Resource groups (RG) in Azure is an approach to group a collection of assets in logical groups for easy or even automatic provisioning, monitoring, and access control, and for more effective management of their costs. The underlying technology that powers resource groups is the Azure Resource Manager (ARM).

Source: onlinetech.com

Q4: What is Kudu? ⭐⭐

Answer: Every Azure App Service web application includes a "hidden" service site called Kudu.

Kudu Console for example is a debugging service for Azure platform which allows you to explore your web app and surf the bugs present on it, like deployment logs, memory dump, and uploading files to your web app, and adding JSON endpoints to your web apps, etc.

Q5: What is Azure Blob Storage? ⭐⭐

Answer: Azure Blob storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data, such as text or binary data. Azure Storage offers three types of blobs:

  • Block blobs store text and binary data, up to about 4.7 TB. Block blobs are made up of blocks of data that can be managed individually.
  • Append blobs are made up of blocks like block blobs, but are optimized for append operations. Append blobs are ideal for scenarios such as logging data from virtual machines.
  • Page blobs store random access files up to 8 TB in size. Page blobs store the VHD files that back VMs.

Source: docs.microsoft.com

Q6: What are stateful and stateless microservices for Service Fabric? ⭐⭐⭐

Answer: Service Fabric enables you to build applications that consist of microservices:

  • Stateless microservices (such as protocol gateways and web proxies) do not maintain a mutable state outside a request and its response from the service. Azure Cloud Services worker roles are an example of a stateless service.

  • Stateful microservices (such as user accounts, databases, devices, shopping carts, and queues) maintain a mutable, authoritative state beyond the request and its response.

Source: quora.com

Q7: What is key vault in Azure? ⭐⭐⭐

Answer: Microsoft Azure Key Vault is a cloud-hosted management service that allows users to encrypt keys and small secrets by using keys that are protected by hardware security modules (HSMs). Small secrets are data less than 10 KB like passwords and .PFX files.

Source: searchwindowsserver.techtarget.com

Q8: What is Azure MFA? ⭐⭐⭐

Answer: Azure Multi-Factor Authentication (MFA) is Microsoft's two-step verification solution. It delivers strong authentication via a range of verification methods, including phone call, text message, or mobile app verification.

Source: docs.microsoft.com

Q9: What is Azure Table Storage? ⭐⭐⭐

Answer: Azure Table storage is a service that stores structured NoSQL data in the cloud, providing a key/attribute store with a schemaless design. Because Table storage is schemaless, it's easy to adapt your data as the needs of your application evolve. Access to Table storage data is fast and cost-effective for many types of applications, and is typically lower in cost than traditional SQL for similar volumes of data.

Source: docs.microsoft.com

Q10: What is Azure Resource Manager and why we need to use one? ⭐⭐⭐

Answer: The Azure Resource Manager (ARM) is the service used to provision resources in your Azure subscription. ARM provides us a way to describe resources in a resource group using JSON documents (ARM Template). by using the ARM Template you have a fully repeatable configuration of a given deployment and this is extremely valuable for Production environments but especially so for Dev/Test deployments. By having a set template, we can ensure that anytime a new Dev or Test deployment is required (which happens all the time), it can be achieved in moments and safe in the knowledge that it will be identical to the previous environments.

Source: codeisahighway.com

Q11: What do you know about Azure WebJobs? ⭐⭐⭐

Answer: WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app, API app, or mobile app. There is no additional cost to use WebJobs.

The Azure WebJobs SDK is a framework that simplifies the task of writing background processing code that runs in Azure WebJobs. It includes a declarative binding and trigger system that works with Azure Storage Blobs, Queues and Tables as well as Service Bus. You could also trigger Azure WebJob using Kudu API.

Source: github.com/Azure

Q12: Is it possible to create a Virtual Machine using Azure Resource Manager in a Virtual Network that was created using classic deployment? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: What is Azure VNET? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: How are Azure Marketplace subscriptions priced? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: What VPN types are supported by Azure? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 19+ Expert Node.js Interview Questions in 2018 | FullStack.Cafe

Q1: What is Node.js? ⭐

Answer: Node.js is a web application framework built on Google Chrome's JavaScript Engine (V8 Engine).

Node.js comes with runtime environment on which a Javascript based script can be interpreted and executed (It is analogus to JVM to JAVA byte code). This runtime allows to execute a JavaScript code on any machine outside a browser. Because of this runtime of Node.js, JavaScript is now can be executed on server as well.

Node.js = Runtime Environment + JavaScript Library

Source: tutorialspoint.com

Q2: What is global installation of dependencies? ⭐⭐

Answer: Globally installed packages/dependencies are stored in /npm directory. Such dependencies can be used in CLI (Command Line Interface) function of any node.js but can not be imported using require() in Node application directly. To install a Node project globally use -g flag.

Source: tutorialspoint.com

Q3: What is an error-first callback? ⭐⭐

Answer: Error-first callbacks are used to pass errors and data. The first argument is always an error object that the programmer has to check if something went wrong. Additional arguments are used to pass data.

fs.readFile(filePath, function(err, data) {
  if (err) {
    //handle the error
  }
  // use the data object
});

Source: tutorialspoint.com

Q4: What are the benefits of using Node.js? ⭐⭐

Answer: Following are main benefits of using Node.js

  • Aynchronous and Event Driven - All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
  • Very Fast - Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.
  • Single Threaded but highly Scalable - Node.js uses a single threaded model with event looping. Event mechanism helps server to respond in a non-bloking ways and makes server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and same program can services much larger number of requests than traditional server like Apache HTTP Server.
  • No Buffering - Node.js applications never buffer any data. These applications simply output the data in chunks.

Source: tutorialspoint.com

Q5: If Node.js is single threaded then how it handles concurrency? ⭐⭐

Answer: Node provides a single thread to programmers so that code can be written easily and without bottleneck. Node internally uses multiple POSIX threads for various I/O operations such as File, DNS, Network calls etc.

When Node gets I/O request it creates or uses a thread to perform that I/O operation and once the operation is done, it pushes the result to the event queue. On each such event, event loop runs and checks the queue and if the execution stack of Node is empty then it adds the queue result to execution stack.

This is how Node manages concurrency.

Source: codeforgeek.com

Q6: How can you avoid callback hells? ⭐⭐⭐

Answer: To do so you have more options:

  • modularization: break callbacks into independent functions
  • use Promises
  • use yield with Generators and/or Promises

Source: tutorialspoint.com

Q7: What's the event loop? ⭐⭐⭐

Answer: The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.

Every I/O requires a callback - once they are done they are pushed onto the event loop for execution. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback may be added to the poll queue to eventually be executed.

Source: blog.risingstack.com

Q8: How Node prevents blocking code? ⭐⭐⭐

Answer: By providing callback function. Callback function gets called whenever corresponding event triggered.

Source: tutorialspoint.com

Q9: What is Event Emmitter? ⭐⭐⭐

Answer: All objects that emit events are members of EventEmitter class. These objects expose an eventEmitter.on() function that allows one or more functions to be attached to named events emitted by the object.

When the EventEmitter object emits an event, all of the functions attached to that specific event are called synchronously.

const EventEmitter = require('events');

class MyEmitter extends EventEmitter {}

const myEmitter = new MyEmitter();
myEmitter.on('event', () => {
  console.log('an event occurred!');
});
myEmitter.emit('event');

Source: tutorialspoint.com

Q10: What tools can be used to assure consistent code style? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: Provide some example of config file separation for dev and prod environments ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: Explain usage of NODE_ENV ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: What are the timing features of Node.js? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: Explain what is Reactor Pattern in Node.js? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: Consider following code snippet ⭐⭐⭐⭐⭐

Details: Consider following code snippet:

{
  console.time("loop");
  for (var i = 0; i < 1000000; i += 1) {
    // Do nothing
  }
  console.timeEnd("loop");
}

The time required to run this code in Google Chrome is considerably more than the time required to run it in Node.js Explain why this is so, even though both use the v8 JavaScript Engine.

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: What is LTS releases of Node.js why should you care? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: Why should you separate Express 'app' and 'server'? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: What is the difference between process.nextTick() and setImmediate() ? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: Rewrite the code sample without try/catch block ⭐⭐⭐⭐⭐

Details: Consider the code:

async function check(req, res) {
  try {
    const a = await someOtherFunction();
    const b = await somethingElseFunction();
    res.send("result")
  } catch (error) {
    res.send(error.stack);
  }
}

Rewrite the code sample without try/catch block.

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 20 .NET Core Interview Questions and Answers | FullStack.Cafe

Q1: What is .NET Core? ⭐

Answer: The .NET Core platform is a new .NET stack that is optimized for open source development and agile delivery on NuGet.

.NET Core has two major components. It includes a small runtime that is built from the same codebase as the .NET Framework CLR. The .NET Core runtime includes the same GC and JIT (RyuJIT), but doesn’t include features like Application Domains or Code Access Security. The runtime is delivered via NuGet, as part of the ASP.NET Core package.

.NET Core also includes the base class libraries. These libraries are largely the same code as the .NET Framework class libraries, but have been factored (removal of dependencies) to enable to ship a smaller set of libraries. These libraries are shipped as System.* NuGet packages on NuGet.org.

Source: stackoverflow.com

Q2: What is the difference between .NET Core and Mono? ⭐⭐

Answer: To be simple:

  • Mono is third party implementation of .Net Framework for Linux/Android/iOs
  • .Net Core is Microsoft's own implementation for same.

Source: stackoverflow.com

Q3: What are some characteristics of .NET Core? ⭐⭐

Answer:

  • Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide.

  • Cross-platform: Runs on Windows, macOS and Linux; can be ported to other OSes. The supported Operating Systems (OS), CPUs and application scenarios will grow over time, provided by Microsoft, other companies, and individuals.

  • Command-line tools: All product scenarios can be exercised at the command-line.

  • Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.

  • Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses. Documentation is licensed under CC-BY. .NET Core is a .NET Foundation project.

  • Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support

Source: stackoverflow.com

Q4: What's the difference between SDK and Runtime in .NET Core? ⭐⭐

Answer:

  • The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.

  • The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.

Source: stackoverflow.com

Q5: What is CTS? ⭐⭐

Answer: The Common Type System (CTS) standardizes the data types of all programming languages using .NET under the umbrella of .NET to a common data type for easy and smooth communication among these .NET languages.

CTS is designed as a singly rooted object hierarchy with System.Object as the base type from which all other types are derived. CTS supports two different kinds of types:

  1. Value Types: Contain the values that need to be stored directly on the stack or allocated inline in a structure. They can be built-in (standard primitive types), user-defined (defined in source code) or enumerations (sets of enumerated values that are represented by labels but stored as a numeric type).
  2. Reference Types: Store a reference to the value‘s memory address and are allocated on the heap. Reference types can be any of the pointer types, interface types or self-describing types (arrays and class types such as user-defined classes, boxed value types and delegates).

Source: c-sharpcorner.com

Q6: What is Kestrel? ⭐⭐⭐

Answer:

  • Kestrel is a cross-platform web server built for ASP.NET Core based on libuv – a cross-platform asynchronous I/O library.
  • It is a default web server pick since it is used in all ASP.NET Core templates.
  • It is really fast.
  • It is secure and good enough to use it without a reverse proxy server. However, it is still recommended that you use IIS, Nginx or Apache or something else.

Source: talkingdotnet.com

Q7: What is difference between .NET Core and .NET Framework? ⭐⭐⭐

Answer: .NET as whole now has 2 flavors:

  • .NET Framework
  • .NET Core

.NET Core and the .NET Framework have (for the most part) a subset-superset relationship. .NET Core is named “Core” since it contains the core features from the .NET Framework, for both the runtime and framework libraries. For example, .NET Core and the .NET Framework share the GC, the JIT and types such as String and List.

.NET Core was created so that .NET could be open source, cross platform and be used in more resource-constrained environments.

Source: stackoverflow.com

Q8: Explain what is included in .NET Core? ⭐⭐⭐

Answer:

  • A .NET runtime, which provides a type system, assembly loading, a garbage collector, native interop and other basic services.

  • A set of framework libraries, which provide primitive data types, app composition types and fundamental utilities.

  • A set of SDK tools and language compilers that enable the base developer experience, available in the .NET Core SDK.

  • The 'dotnet' app host, which is used to launch .NET Core apps. It selects the runtime and hosts the runtime, provides an assembly loading policy and launches the app. The same host is also used to launch SDK tools in much the same way.

Source: stackoverflow.com

Q9: What's the difference between .NET Core, .NET Framework, and Xamarin? ⭐⭐⭐

Answer:

  • .NET Framework is the "full" or "traditional" flavor of .NET that's distributed with Windows. Use this when you are building a desktop Windows or UWP app, or working with older ASP.NET 4.6+.
  • .NET Core is cross-platform .NET that runs on Windows, Mac, and Linux. Use this when you want to build console or web apps that can run on any platform, including inside Docker containers. This does not include UWP/desktop apps currently.
  • Xamarin is used for building mobile apps that can run on iOS, Android, or Windows Phone devices.

Xamarin usually runs on top of Mono, which is a version of .NET that was built for cross-platform support before Microsoft decided to officially go cross-platform with .NET Core. Like Xamarin, the Unity platform also runs on top of Mono.

Source: stackoverflow.com

Q10: What is CoreCLR? ⭐⭐⭐

Answer: CoreCLR is the .NET execution engine in .NET Core, performing functions such as garbage collection and compilation to machine code.

Consider:

Source: blogs.msdn.microsoft.com

Q11: Explain the difference between Task and Thread in .NET ⭐⭐⭐

Answer:

  • Thread represents an actual OS-level thread, with its own stack and kernel resources. Thread allows the highest degree of control; you can Abort() or Suspend() or Resume() a thread, you can observe its state, and you can set thread-level properties like the stack size, apartment state, or culture. ThreadPool is a wrapper around a pool of threads maintained by the CLR.

  • The Task class from the Task Parallel Library offers the best of both worlds. Like the ThreadPool, a task does not create its own OS thread. Instead, tasks are executed by a TaskScheduler; the default scheduler simply runs on the ThreadPool. Unlike the ThreadPool, Task also allows you to find out when it finishes, and (via the generic Task) to return a result.

Source: stackoverflow.com

Q12: What is JIT compiler? ⭐⭐⭐

Answer: Before a computer can execute the source code, special programs called compilers must rewrite it into machine instructions, also known as object code. This process (commonly referred to simply as “compilation”) can be done explicitly or implicitly.

Implicit compilation is a two-step process:

  • The first step is converting the source code to intermediate language (IL) by a language-specific compiler.
  • The second step is converting the IL to machine instructions. The main difference with the explicit compilers is that only executed fragments of IL code are compiled into machine instructions, at runtime. The .NET framework calls this compiler the JIT (Just-In-Time) compiler.

Source: telerik.com

Q13: What are the benefits of explicit compilation? ⭐⭐⭐

Answer: Ahead of time (AOT) delivers faster start-up time, especially in large applications where much code executes on startup. But it requires more disk space and more memory/virtual address space to keep both the IL and precompiled images. In this case the JIT Compiler has to do a lot of disk I/O actions, which are quite expensive.

Source: telerik.com

Q14: When should we use .NET Core and .NET Standard Class Library project types? ⭐⭐⭐

Answer:

  • Use a .NET Standard library when you want to increase the number of apps that will be compatible with your library, and you are okay with a decrease in the .NET API surface area your library can access.

  • Use a .NET Core library when you want to increase the .NET API surface area your library can access, and you are okay with allowing only .NET Core apps to be compatible with your library.

Source: stackoverflow.com

Q15: What's the difference between RyuJIT and Roslyn? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: What is the difference between AppDomain, Assembly, Process, and a Thread? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: Explain Finalize vs Dispose usage? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: How many types of JIT Compilations do you know? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: Can ASP.NET Core work with the .NET framework? ⭐⭐

Answer: Yes. This might surprise many, but ASP.NET Core works with .NET framework and this is officially supported by Microsoft.

ASP.NET Core works with:

  • .NET Core framework
  • .NET framework

Source: talkingdotnet.com

Q20: What is the equivalent of WebForms in ASP.NET Core? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 20 Basic TypeScript Interview Questions (2018 Edition) | FullStack.Cafe

Q1: What is TypeScript and why would I use it in place of JavaScript? ⭐

Details:

Answer: TypeScript is a superset of JavaScript which primarily provides optional static typing, classes and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code. For a large JavaScript project, adopting TypeScript might result in more robust software, while still being deployable where a regular JavaScript application would run.

In details:

  • TypeScript supports new ECMAScript standards and compiles them to (older) ECMAScript targets of your choosing. This means that you can use features of ES2015 and beyond, like modules, lambda functions, classes, the spread operator, destructuring, today.
  • JavaScript code is valid TypeScript code; TypeScript is a superset of JavaScript.
  • TypeScript adds type support to JavaScript. The type system of TypeScript is relatively rich and includes: interfaces, enums, hybrid types, generics, union and intersection types, access modifiers and much more. TypeScript makes typing a bit easier and a lot less explicit by the usage of type inference.
  • The development experience with TypeScript is a great improvement over JavaScript. The IDE is informed in real-time by the TypeScript compiler on its rich type information.
  • With strict null checks enabled (--strictNullChecks compiler flag) the TypeScript compiler will not allow undefined to be assigned to a variable unless you explicitly declare it to be of nullable type.
  • To use TypeScript you need a build process to compile to JavaScript code. The TypeScript compiler can inline source map information in the generated .js files or create separate .map files. This makes it possible for you to set breakpoints and inspect variables during runtime directly on your TypeScript code.
  • TypeScript is open source (Apache 2 licensed, see github) and backed by Microsoft. Anders Hejlsberg, the lead architect of C# is spearheading the project.

Source: stackoverflow.com

Q2: Explain generics in TypeScript ⭐

Answer: Generics are able to create a component or function to work over a variety of types rather than a single one.

/** A class definition with a generic parameter */
class Queue<T> {
  private data = [];
  push = (item: T) => this.data.push(item);
  pop = (): T => this.data.shift();
}

const queue = new Queue<number>();
queue.push(0);
queue.push("1"); // ERROR : cannot push a string. Only numbers allowed

Source: basarat.gitbooks.io

Q3: Does TypeScript support all object oriented principles? ⭐⭐

Answer: The answer is YES. There are 4 main principles to Object Oriented Programming:

  • Encapsulation,
  • Inheritance,
  • Abstraction, and
  • Polymorphism.

TypeScript can implement all four of them with its smaller and cleaner syntax.

Source: jonathanmh.com

Q4: How could you check null and undefined in TypeScript? ⭐⭐

Answer: Just use:

if (value) {
}

It will evaluate to true if value is not:

  • null
  • undefined
  • NaN
  • empty string ''
  • 0
  • false

TypesScript includes JavaScript rules.

Source: stackoverflow.com

Q5: How to implement class constants in TypeScript? ⭐⭐

Answer: In TypeScript, the const keyword cannot be used to declare class properties. Doing so causes the compiler to an error with "A class member cannot have the 'const' keyword." TypeScript 2.0 has the readonly modifier:

class MyClass {
    readonly myReadonlyProperty = 1;

    myMethod() {
        console.log(this.myReadonlyProperty);
    }
}

new MyClass().myReadonlyProperty = 5; // error, readonly

Source: stackoverflow.com

Q6: What is a TypeScript Map file? ⭐⭐

Answer: .map files are source map files that let tools map between the emitted JavaScript code and the TypeScript source files that created it. Many debuggers (e.g. Visual Studio or Chrome's dev tools) can consume these files so you can debug the TypeScript file instead of the JavaScript file.

Source: stackoverflow.com

Q7: What is getters/setters in TypeScript? ⭐⭐

Answer: TypeScript supports getters/setters as a way of intercepting accesses to a member of an object. This gives you a way of having finer-grained control over how a member is accessed on each object.

class foo {
  private _bar:boolean = false;

  get bar():boolean {
    return this._bar;
  }
  set bar(theBar:boolean) {
    this._bar = theBar;
  }
}

var myBar = myFoo.bar;  // correct (get)
myFoo.bar = true;  // correct (set)

Source: typescriptlang.org

Q8: Could we use TypeScript on backend and how? ⭐⭐

Answer: Typescript doesn’t only work for browser or frontend code, you can also choose to write your backend applications. For example you could choose Node.js and have some additional type safety and the other abstraction that the language brings.

  1. Install the default Typescript compiler
npm i -g typescript
  1. The TypeScript compiler takes options in the shape of a tsconfig.json file that determines where to put built files and in general is pretty similar to a babel or webpack config.
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "declaration": true,
    "outDir": "build"
  }
}
  1. Compile ts files
tsc
  1. Run
node build/index.js

Source: jonathanmh.com

Q9: What are different components of TypeScript? ⭐⭐⭐

Answer: There are mainly 3 components of TypeScript .

  1. Language – The most important part for developers is the new language. The language consist of new syntax, keywords and allows you to write TypeScript.
  2. Compiler – The TypeScript compiler is open source, cross-platform and open specification, and is written in TypeScript. Compiler will compile your TypeScript into JavaScript. And it will also emit error, if any. It can also help in concating different files to single output file and in generating source maps.
  3. Language Service – TypeScript language service which powers the interactive TypeScript experience in Visual Studio, VS Code, Sublime, the TypeScript playground and other editor.

Source: talkingdotnet.com

Q10: Is that TypeScript code valid? Explain why. ⭐⭐⭐

Details: Consider:

class Point {
    x: number;
    y: number;
}

interface Point3d extends Point {
    z: number;
}

let point3d: Point3d = {x: 1, y: 2, z: 3};

Answer: Yes, the code is valid. A class declaration creates two things: a type representing instances of the class and a constructor function. Because classes create types, you can use them in the same places you would be able to use interfaces.

Source: typescriptlang.org

Q11: Explain how and why we could use property decorators in TS? ⭐⭐⭐

Answer: Decorators can be used to modify the behavior of a class or become even more powerful when integrated into a framework. For instance, if your framework has methods with restricted access requirements (just for admin), it would be easy to write an @admin method decorator to deny access to non-administrative users, or an @owner decorator to only allow the owner of an object the ability to modify it.

class CRUD {
    get() { }
    post() { }
 
    @admin
    delete() { }
 
    @owner
    put() { }
}

Source: www.sitepen.com

Q12: Are strongly-typed functions as parameters possible in TypeScript? ⭐⭐⭐

Details: Consider the code:

class Foo {
    save(callback: Function) : void {
        //Do the save
        var result : number = 42; //We get a number from the save operation
        //Can I at compile-time ensure the callback accepts a single parameter of type number somehow?
        callback(result);
    }
}

var foo = new Foo();
var callback = (result: string) : void => {
    alert(result);
}
foo.save(callback);

Can you make the result parameter in save a type-safe function? Rewrite the code to demonstrate.

Answer:

In TypeScript you can declare your callback type like:

type NumberCallback = (n: number) => any;

class Foo {
    // Equivalent
    save(callback: NumberCallback): void {
        console.log(1)
        callback(42);
    }
}

var numCallback: NumberCallback = (result: number) : void => {
    console.log("numCallback: ", result.toString());
}

var foo = new Foo();
foo.save(numCallback)

Source: stackoverflow.com

Q13: How can you allow classes defined in a module to accessible outside of the module? ⭐⭐⭐

Answer: Classes define in a module are available within the module. Outside the module you can’t access them.

module Vehicle {
    class Car {
        constructor (
            public make: string, 
            public model: string) { }
    }
    var audiCar = new Car("Audi", "Q7");
}
// This won't work
var fordCar = Vehicle.Car("Ford", "Figo");

As per above code, fordCar variable will give us compile time error. To make classes accessible outside module use export keyword for classes.

module Vehicle {
    export class Car {
        constructor (
            public make: string, 
            public model: string) { }
    }
    var audiCar = new Car("Audi", "Q7");
}
// This works now
var fordCar = Vehicle.Car("Ford", "Figo");

Source: http://www.talkingdotnet.com

Q14: Does TypeScript supports function overloading? ⭐⭐⭐

Answer: Yes, TypeScript does support function overloading but the implementation is a bit different if we compare it to OO languages. We are creating just one function and a number of declarations so that TypeScript doesn't give compile errors. When this code is compiled to JavaScript, the concrete function alone will be visible. As a JavaScript function can be called by passing multiple arguments, it just works.

class Foo {
    myMethod(a: string);
    myMethod(a: number);
    myMethod(a: number, b: string);
    myMethod(a: any, b?: string) {
        alert(a.toString());
    }
}

Source: typescriptlang.org

Q15: Explain why that code is marked as WRONG? ⭐⭐⭐⭐

Details:

/* WRONG */
interface Fetcher {
    getObject(done: (data: any, elapsedTime?: number) => void): void;
}

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: How would you overload a class constructor in TypeScript? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: What is the difference between "interface vs type" statements? ⭐⭐⭐⭐

Details:

interface X {
    a: number
    b: string
}

type X = {
    a: number
    b: string
};

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Explain when to use "declare" keyword in TypeScript ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: What are Ambients in TypeScripts and when to use them? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: Is it possible to generate TypeScript declaration files from JS library? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 20 Reactive Programming Interview Questions To Polish Up In 2019 | FullStack.Cafe

Q1: What is the difference between BehaviorSubject vs Observable? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q2: What is the Reactive Manifesto? ⭐⭐

Answer: The Reactive Manifesto is a document that defines the core principles of reactive programming. It was first released in 2013 by a group of developers led by a man called Jonas Boner. The Reactive Manifesto underpins the principles of reactive programming.

Source: reactivemanifesto.org

Q3: What is Reactive Programming? ⭐⭐

Answer: Reactive programming is programming with asynchronous data streams. Event buses or your typical click events are really an asynchronous event stream, on which you can observe and do some side effects. Reactive is that idea on steroids. You are able to create data streams of anything, not just from click and hover events. Streams are cheap and ubiquitous, anything can be a stream: variables, user inputs, properties, caches, data structures, etc. For example, imagine your Twitter feed would be a data stream in the same fashion that click events are. You can listen to that stream and react accordingly.

Source: github.com

Q4: What is Stream? ⭐⭐

Answer: A stream is a sequence of ongoing events ordered in time. It can emit three different things: a value (of some type), an error, or a "completed" signal.

Source: github.com

Q5: What Are Some Advantages of Reactive Programming? ⭐⭐

Answer: Here’s a short list of advantages :

  • avoid “callback hell”
  • a lot simpler to do async / threaded work
  • a lot of operators that simplify work
  • very simple to compose streams of data
  • complex threading becomes very easy
  • you end up with a more cleaner, readable code base
  • easy to implement back-pressure

Source: medium.com

Q6: What Does Asynchrony Mean in the Context of Reactive Systems? ⭐⭐⭐

Answer: The Oxford Dictionary defines asynchronous as “not existing or occurring at the same time”. In the context of Reactive Sysytems, it means that the processing of a request occurs at an arbitrary point in time, sometime after it has been transmitted from client to service. The client cannot directly observe, or synchronize with, the execution that occurs within the service. This is the antonym of synchronous processing which implies that the client only resumes its own execution once the service has processed the request.

Source: reactivemanifesto.org

Q7: What is Back-Pressure? ⭐⭐⭐

Answer: When one component is struggling to keep-up, the system as a whole needs to respond in a sensible way. It is unacceptable for the component under stress to fail catastrophically or to drop messages in an uncontrolled fashion. Since it can’t cope and it can’t fail it should communicate the fact that it is under stress to upstream components and so get them to reduce the load. This back-pressure is an important feedback mechanism that allows systems to gracefully respond to load rather than collapse under it. The back-pressure may cascade all the way up to the user, at which point responsiveness may degrade, but this mechanism will ensure that the system is resilient under load, and will provide information that may allow the system itself to apply other resources to help distribute the load.

Source: reactivemanifesto.org

Q8: What is Elasticity (in contrast to Scalability)? ⭐⭐⭐

Answer: Elasticity means that the throughput of a system scales up or down automatically to meet varying demand as resource is proportionally added or removed. The system needs to be scalable to allow it to benefit from the dynamic addition, or removal, of resources at runtime. Elasticity therefore builds upon scalability and expands on it by adding the notion of automatic resource management.

Source: reactivemanifesto.org

Q9: Explain the Term Non-Blocking ⭐⭐⭐

Answer: In concurrent programming an algorithm is considered non-blocking if threads competing for a resource do not have their execution indefinitely postponed by mutual exclusion protecting that resource. In practice this usually manifests as an API that allows access to the resource if it is available otherwise it immediately returns informing the caller that the resource is not currently available or that the operation has been initiated and not yet completed. A non-blocking API to a resource allows the caller the option to do other work rather than be blocked waiting on the resource to become available. This may be complemented by allowing the client of the resource to register for getting notified when the resource is available or the operation has completed.

Source: reactivemanifesto.org

Q10: What is Actor Model? ⭐⭐⭐

Answer: All Actor model says that your concurrency primitives are actors, which can:

  • receive a message and decide what to do next depending on the content of the message, including:
  • send messages to any actors they know about
  • create new actors

and provides certain guarantees, e.g.:

  • any actor will only handle a single message at a time
  • messages sent by actor X to actor Y will arrive in the order thay were sent

Source: github.com

Q11: Describe Difference Between Reactive Programming vs Imperative Programming ⭐⭐⭐

Answer: In reactive programming, Observables emit data, and send it to the subscribers. This can be seen as data being PUSHed in reactive programming, as opposed to data being PULLed in imperative programming, where you explicitly request data (iterating over collection, requesting data from the DB, etc).

Source: medium.com

Q12: What Does It Mean to be Resilient for a Reactive System? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: What Does It Mean to be Elastic for a Reactive System? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: Explain Failure in Contrast to Error ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: What is Difference Between Observer Pattern and Reactive Programming? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: Imperative vs Functional vs Reactive Programming. Explain. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: What does Amdahl's Law mean? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Explain Message-Driven vs Event-Driven Approaches ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: What are the core principles of Redux? ⭐⭐

Answer: Redux follows three fundamental principles:

  1. Single source of truth: The state of your whole application is stored in an object tree within a single store. The single state tree makes it easier to keep track of changes over time and debug or inspect the application.
  2. State is ready only: The only way to change the state is to emit an action, an object describing what happened. This ensures that neither the views nor the network callbacks will ever write directly to the state.
  3. Changes are made with pure functions: To specify how the state tree is transformed by actions, you write pure reducers(Reducers are just pure functions that take the previous state and an action, and return the next state).

Source: github.com/sudheerj

Q20: Are there any similarities between Redux and RxJS? ⭐⭐⭐

Answer: These libraries are very different for very different purposes, but there are some vague similarities.

  • Redux is a tool for managing state throughout the application. It is usually used as an architecture for UIs. Think of it as an alternative to (half of) Angular.

  • RxJS is a reactive programming library. It is usually used as a tool to accomplish asynchronous tasks in JavaScript. Think of it as an alternative to Promises.

Redux uses the Reactive paradigm little bit because the Store is reactive. The Store observes actions from a distance, and changes itself. RxJS also uses the Reactive paradigm, but instead of being an architecture, it gives you basic building blocks, Observables, to accomplish this "observing from a distance" pattern.

Source: github.com/sudheerj

Originally published on 👉 20 Senior .NET Developer Interview Questions to Ask in 2019 | FullStack.Cafe

Q1: What is .NET Standard? ⭐⭐⭐

Answer:

  • .NET Standard solves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud services
  • .NET Standard is a set of APIs that all .NET platforms have to implement. This unifies the .NET platforms and prevents future fragmentation.
  • .NET Standard 2.0 will be implemented by .NET Framework, .NET Core, and Xamarin. For .NET Core, this will add many of the existing APIs that have been requested.
  • .NET Standard 2.0 includes a compatibility shim for .NET Framework binaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.
  • .NET Standard will replace Portable Class Libraries (PCLs) as the tooling story for building multi-platform .NET libraries.

Source: talkingdotnet.com

Q2: Explain the difference between Task and Thread in .NET ⭐⭐⭐

Answer:

  • Thread represents an actual OS-level thread, with its own stack and kernel resources. Thread allows the highest degree of control; you can Abort() or Suspend() or Resume() a thread, you can observe its state, and you can set thread-level properties like the stack size, apartment state, or culture. ThreadPool is a wrapper around a pool of threads maintained by the CLR.

  • The Task class from the Task Parallel Library offers the best of both worlds. Like the ThreadPool, a task does not create its own OS thread. Instead, tasks are executed by a TaskScheduler; the default scheduler simply runs on the ThreadPool. Unlike the ThreadPool, Task also allows you to find out when it finishes, and (via the generic Task) to return a result.

Source: stackoverflow.com

Q3: Explain Finalize vs Dispose usage? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q4: What is difference between WCF and Web API and WCF REST and Web Service? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q5: What do you know about Azure WebJobs? ⭐⭐⭐

Answer: WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app, API app, or mobile app. There is no additional cost to use WebJobs.

The Azure WebJobs SDK is a framework that simplifies the task of writing background processing code that runs in Azure WebJobs. It includes a declarative binding and trigger system that works with Azure Storage Blobs, Queues and Tables as well as Service Bus. You could also trigger Azure WebJob using Kudu API.

Source: github.com/Azure

Q6: What is difference between constants and readonly? ⭐⭐⭐

Answer: Constant variables are declared and initialized at compile time. The value can't be changed afterwards. Readonly is used only when we want to assign the value at run time.

Source: guru99.com

Q7: Refactor the code ⭐⭐⭐

Details:

class ClassA
{
  public ClassA() { }

  public ClassA(int pValue) {  }
}

// client program
class Program
{
  static void Main(string[] args)
  {
    ClassA refA = new ClassA();
  }
}

Is there a way to modify ClassA so that you can you call the constructor with parameters, when the Main method is called, without creating any other new instances of the ClassA?

Answer: The this keyword is used to call other constructors, to initialize the class object. The following shows the implementation:

class ClassA
{
  public ClassA() : this(10)
  { }

  public ClassA(int pValue)
  {  }
}

Source: toptal.com

Q8: What is lambda expressions in C#? ⭐⭐⭐

Answer: A lambda expression is an anonymous function that you can use to create delegates or expression tree types. By using lambda expressions, you can write local functions that can be passed as arguments or returned as the value of function calls. Lambda expressions are particularly helpful for writing LINQ query expressions.

Source: docs.microsoft.com

Q9: What is Indexer in C#? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q10: What is the "yield" keyword used for in C#? ⭐⭐⭐⭐

Details: Consider:

IEnumerable<object> FilteredList()
{
    foreach( object item in FullList )
    {
        if( IsItemInPartialList( item )
            yield return item;
    }
}

Could you explain what does the yield keyword do there?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: Can you create sealed abstract class in C#? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: Implement the "Where" method in C# ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: What is Facade pattern? ⭐⭐⭐

Answer: Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. This type of design pattern comes under structural pattern as this pattern adds an interface to existing system to hide its complexities.

This pattern involves a single class which provides simplified methods required by client and delegates calls to methods of existing system classes.

Source: tutorialspoint.com

Q14: What's the difference between the Dependency Injection and Service Locator patterns? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: Define what is Let clause? ⭐⭐⭐

Answer: In a query expression, it is sometimes useful to store the result of a sub-expression in order to use it in subsequent clauses. You can do this with the let keyword, which creates a new range variable and initializes it with the result of the expression you supply.

Consider:

var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" };
var result =
    from animalName in names
    let nameLength = animalName.Length
    where nameLength > 3
    orderby nameLength
    select animalName; 

Source: career.guru99.com

Q16: Name some advantages of LINQ over Stored Procedures ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: Why do we use MSMQ? ⭐⭐

Answer: Microsoft Message Queuing, or MSMQ, is technology for asynchronous messaging. Whenever there's need for two or more applications (processes) to send messages to each other without having to immediately know results, MSMQ can be used. MSMQ can communicate between remote machines, even over Internet. It's free and comes with Windows, but is not installed by default.

This mainly addresses the common use case of asynchronous message processing: you have a service Service1 that communicates (send messages) with another part of your software architecture, say Service2.

Main problem: what if Service2 becomes suddenly unavailable? Will messages be lost? If you use MSMQ it won't: Service1 will send messages into a queue, and Service2 will dequeue when it is available.

MSMQ will resolve following common issues:

  • temporary unavailability of a service: messages are persisted on the disk and will be dequeued when the service becomes available again, so no messages are lost
  • as it's fully asynchronous, it'll help a lot in case of punctual peak load: your Service2 won't die under the heavy load, it'll just dequeue and process messages, one after one

Source: cogin.com

Q18: Explain the Single Responsibility Principle? ⭐⭐⭐

Answer: Single responsibility is the concept of a Class doing one specific thing (responsibility) and not trying to do more than it should, which is also referred to as High Cohesion.

Classes don't often start out with Low Cohesion, but typically after several releases and different developers adding onto them, suddenly you'll notice that it became a monster or God class as some call it. So the class should be refactored.

Source: stackoverflow.com

Q19: What is GOD class and why should we avoid it? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: When would you use Duplex WCF service? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 20 Vue.js Interview Questions And Answers (2018 Updated) | FullStack.Cafe

Q1: What is Vue.js? ⭐

Answer: Vue js is progressive javascript script used to create dynamic user interfaces.Vue js is very easy to learn.In order to work with Vue js you just need to add few dynamic features to a website.You don’t need to install any thing to use Vue js just need add Vue js library in your project.

Source: onlineinterviewquestions.com

Q2: How to create an instance of Vue.js? ⭐

Answer: Every Vue application starts by creating a new Vue instance with the Vue function:

var vm = new Vue({
  // options
})

Source: onlineinterviewquestions.com

Q3: Explain the differences between one-way data flow and two-way data binding? ⭐⭐

Answer: In one-way data flow the view(UI) part of application does not updates automatically when data Model is change we need to write some custom code to make it updated every time a data model is changed. In Vue js v-bind is used for one-way data flow or binding.

In two-way data binding the view(UI) part of application automatically updates when data Model is changed. In Vue.js v-model directive is used for two way data binding.

Source: onlineinterviewquestions.com

Q4: How to create Two-Way Bindings in Vue.js? ⭐⭐

Answer: v-model directive is used to create Two-Way Bindings in Vue js.In Two-Way Bindings data or model is bind with DOM and Dom is binded back to model.

In below example you can see how Two-Way Bindings is implemented.

<div id="app">
  {{message}}
  <input v-model="message">
</div>
<script type="text/javascript">
  var message = 'Vue.js is rad';
  new Vue({ el: '#app', data: { message } });
</script>

Source: onlineinterviewquestions.com

Q5: What are components props? ⭐⭐

Answer: Every component instance has its own isolated scope. This means you cannot (and should not) directly reference parent data in a child component’s template. Data can be passed down to child components using props. Props are custom attributes you can register on a component. When a value is passed to a prop attribute, it becomes a property on that component instance.

Vue.component('blog-post', {
  // camelCase in JavaScript
  props: ['postTitle'],
  template: '<h3>{{ postTitle }}</h3>'
})

Source: stackoverflow.com

Q6: How to deploy Vue.js app? ⭐⭐

Answer: If you've created your project like this:

vue init webpack myproject

Now you can run

npm run build

Then copy index.html and /dist/ folder into your website root directory. Done.

Source: stackoverflow.com

Q7: What are Components in Vue.js? ⭐⭐

Answer: Components are one of most powerful features of Vue js.In Vue components are custom elements that help extend basic HTML elements to encapsulate reusable code.

Following is the way to register a Vue component inside another component:

export default {
  el: '#your-element'
  components: {
      'your-component'
  }
}

Source: onlineinterviewquestions.com

Q8: What is filters in Vue.js? ⭐⭐

Answer: Vue.js allows you to define filters that can be used to apply common text formatting. Filters are usable in two places: mustache interpolations and v-bind expressions (the latter supported in 2.1.0+). Filters should be appended to the end of the JavaScript expression, denoted by the “pipe” symbol:

<!-- in mustaches -->
{{ message | capitalize }}

<!-- in v-bind -->
<div v-bind:id="rawId | formatId"></div>

Source: stackoverflow.com

Q9: How can you redirect to another page in Vue.js? ⭐⭐

Answer: If you are using vue-router, you should use router.go(path) to navigate to any particular route. The router can be accessed from within a component using this.$router. router.go() changed in VueJS 2.0. You can use router.push({ name: "yourroutename"})or just router.push("yourroutename") now to redirect.

Q10: Explain the basic logical Vue.js app organisation ⭐⭐

Answer: A Vue.js application consists of a root Vue instance created with new Vue, optionally organized into a tree of nested, reusable components. For example, a todo app’s component tree might look like this:

Root Instance
└─ TodoList
   ├─ TodoItem
   │  ├─ DeleteTodoButton
   │  └─ EditTodoButton
   └─ TodoListFooter
      ├─ ClearTodosButton
      └─ TodoListStatistics

All Vue components are also Vue instances.

Source: vuejs.org

Q11: List some features of Vue.js ⭐⭐

Answer: Vue js comes with following features

  • Templates
  • Reactivity
  • Components
  • Transitions
  • Routing

Source: onlineinterviewquestions.com

Q12: How can I fetch query parameters in Vue.js? ⭐⭐

Answer: You have access to a $route object from your components, that expose what we need.

//from your component
console.log(this.$route.query.test)

Source: stackoverflow.com

Q13: What is the difference v-bind and v-model? Provide some code example. ⭐⭐⭐

Answer: v-model is a two-way binding for form inputs. It combines v-bind, which **brings a js value **into the markup, and v-on:input to update the js value.

Consider:

<input v-model="something">

and it's just syntactic sugar for:

<input
   v-bind:value="something"
   v-on:input="something = $event.target.value"
>

v-model works with all the basic HTML input types (text, textarea, number, radio, checkbox, select). You can use v-model with input type=date if your model stores dates as ISO strings (yyyy-mm-dd).

Source: stackoverflow.com

Q14: How to pass an argument to Vue.js filters? ⭐⭐⭐

Answer: Consider:

filters:{
   currency: function(value, arg1){
     return arg1+value;
}

And usage:

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.1/vue.js"></script>
<div id="vue-instance">
  {{123 | currency('$') }}
</div>

Source: stackoverflow.com

Q15: How to use Gulp with Vue.js? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: What's the equivalent of Angular Service in Vue.js? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: What is Vuex? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Why we need Vue.js mixins? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: What is the best way to create a constant, that can be accessible from entire application in VueJs ? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: What is a proper way to communicate between sibling components in vuejs 2.0? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 20+ Agile Scrum Interview Questions for Software Developers in 2018 | FullStack.Cafe

[⬆] <a name=22EssentialWCFInterviewQuestionsThat'llMakeYouCry>22 Essential WCF Interview Questions That'll Make You Cry

Originally published on 👉 22 Essential WCF Interview Questions That'll Make You Cry | FullStack.Cafe

Q1: What is WCF? ⭐

Answer: Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data.

Source: docs.microsoft.com

Q2: Could you name basic WCF service components? ⭐⭐

Answer: Have a look at this mindmap to navigate yourself through WCF service components:

Source: codeproject.com

Q3: What is a service contract in WCF? ⭐⭐

Answer: A service contract defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do. It may have service-level settings, such as the name of the service and namespace for the service.

[ServiceContract]
interface IMyContract { 
    [OperationContract]
	string MyMethod();
}

class MyService: IMyContract {
	public string MyMethod() {
		return "Hello World";
	}
}

Source: dotnettricks.com

Q4: Explain what is SOA? ⭐⭐

Answer: SOA stands for **service-oriented architecture. Service Oriented Architecture is an architectural approach in software development where the application is organized as "Services". Services are a group of methods that contain the business logic to connect a DB or other services. For instance you go to a hotel and order food. Your order first goes to the counter and then it goes to the kitchen where the food is prepared and finally the waiter serves the food.

Some important characteristics of Service Oriented Architecture

  • SOA services should be independent of other services. Altering a service should not affect the client calling the service.
  • Services should be **self-contained. ** Services should be able to define themselves (in the Web Service Description Language (WSDL)). It should be able to tell the client what all of the operations it does, what are all the data types it uses and what kind of value it will return.

Source: c-sharpcorner.com

Q5: What are the features and advantage of WCF? ⭐⭐

Answer: Features of WCF**

Windows Communication Foundation (WCF) is a secure, reliable, and scalable messaging platform for the .NET Framework 3.0,

  • Service Orientation
  • Interoperability
  • Multiple Message Patterns
  • Service Metadata
  • Data Contracts
  • Security
  • Multiple Transports and Encodings
  • Reliable and Queued Messages
  • Durable Messages
  • Transactions
  • AJAX and REST Support
  • Extensibility

Advantages of WCF:

  1. Service Oriented
  2. Location Independent
  3. Language Independent
  4. Platform Independent
  5. Support Multiple operation
  6. WCF can maintain transaction like COM+ Does
  7. It can maintain state
  8. It can control concurrency
  9. It can be hosted on IIS, WAS, Self hosting, Windows services.

Source: docs.microsoft.com

Q6: What is transport in WCF? ⭐⭐⭐

Answer: The WCF programming model separates endpoint operations (as expressed in a service contract) from the transport mechanism that connects two endpoints. This gives you the flexibility to decide how to expose your services to the network. The transport layer is at the lowest level of the channel stack. A transport sends or receives the serialized form of a message to or from another application. The main transports used in Windows Communication Foundation (WCF) are:

  • HTTP,
  • HTTPS,
  • TCP
  • named pipes.

Source: weblogs.asp.net

Q7: What is WCF Binding and how many of them do you know? ⭐⭐⭐

Answer: Bindings specify how a Windows Communication Foundation (WCF) service endpoint communicates with other endpoints. At its most basic, a binding must specify the transport (for example, HTTP or TCP) to use. You can also set other characteristics, such as security and transaction support, through bindings.

WCF provides nine built-in bindings:

  • BasicHttpBinding: Basic web service communication. Exposes WCF services as legacy ASMX web services. Used for interoperability. No security by default.
  • WSHttpBinding: Web services with WS-* support. Supports transactions and reliable messaging.
  • WSDualHttpBinding: Web services with duplex contract and transaction support.
  • WSFederationHttpBinding: Web services with federated security. Supports transactions.
  • MsmqIntegrationBinding: Communication directly with MSMQ applications. Supports transactions.
  • NetMsmqBinding: Communication between WCF applications by using queuing. Supports transactions.
  • NetNamedPipeBinding: Communication between WCF applications on same computer. Supports duplex contracts and transactions.
  • NetPeerTcpBinding: Communication between computers across peer-to-peer services. Supports duplex contracts.
  • NetTcpBinding: Communication between WCF applications across computers. Supports duplex contracts and transactions.

Source: weblogs.asp.net

Q8: What are the Possible Ways of Hosting a WCF Service? ⭐⭐⭐

Answer: For a Windows Communication Foundation service to host, we need at least a managed process, a ServiceHost instance and an Endpoint configured. Possible approaches for hosting a service are:

  1. Hosting in a Managed Application/Self Hosting
    1. Console Application
    2. Windows Application
    3. Windows Service
  2. Hosting on Web Server
    1. IIS 6.0 (ASP.NET Application supports only HTTP)
    2. Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP, NamedPipes, MSMQ.

Source: codeproject.com

Q9: What is Message Contract in WCF? ⭐⭐⭐

Answer: Sometimes complete control over the structure of a SOAP message is just as important as control over its contents (that defined by Data Contracts). This is especially true when interoperability is important or to specifically control security issues at the level of the message or message part. In these cases, you can create a message contract that enables you to specify the structure of the precise SOAP message required.

Source: c-sharpcorner.com

Q10: What is an Operation Contract in WCF? ⭐⭐⭐

Answer: An operation contract is defined within a service contract. It defines the parameters and return type of an operation. An operation contract can also defines operation-level settings, like as the transaction flow of the operation, the directions of the operation (one-way, two-way, or both ways), and fault contract of the operation.

[ServiceContract]
interface IMyContract { 
    [FaultContract(typeof(MyFaultContract))]
    [OperationContract]
	string MyMethod();
}

Source: dotnettricks.com

Q11: Name some different types of contracts in WCF ⭐⭐⭐

Answer: WCF contract specifies the service and its operations. WCF has five types of contracts:

  • service contract,
  • operation contract,
  • data contract,
  • message contract
  • fault contract.

Source: dotnettricks.com

Q12: Explain the difference between WCF vs ASP.NET Web API? ⭐⭐⭐

Answer: In the scenarios listed below you should go for WCF:

  • If you need to send data on protocols like TCP, MSMQ or MIME
  • If the consuming client just knows how to consume SOAP messages WEB API is a framework for developing RESTful/HTTP services.

Consider:

WCF ASP.NET Web API
Enables building services that support multiple transport protocols (HTTP, TCP, UDP, and custom transports) and allows switching between them. HTTP only. First-class programming model for HTTP. More suitable for access from various browsers, mobile devices etc enabling wide reach.
Enables building services that support multiple encodings (Text, MTOM, and Binary) of the same message type and allows switching between them. Enables building Web APIs that support wide variety of media types including XML, JSON etc.
Supports building services with WS-* standards like Reliable Messaging, Transactions, Message Security. Uses basic protocol and formats such as HTTP, WebSockets, SSL, JSON, and XML. There is no support for higher level protocols such as Reliable Messaging or Transactions.
Supports Request-Reply, One Way, and Duplex message exchange patterns. HTTP is request/response but additional patterns can be supported through SignalR and WebSockets integration.
WCF SOAP services can be described in WSDL allowing automated tools to generate client proxies even for services with complex schemas. There is a variety of ways to describe a Web API ranging from auto-generated HTML help page describing snippets to structured metadata for OData integrated APIs.
Ships with the .NET framework. Ships with .NET framework but is open-source and is also available out-of-band as independent download.

Source: stackoverflow.com

Q13: Why we need Streaming? ⭐⭐⭐

Answer: When you have a large amount of data to transfer, the streaming transfer mode in WCF is a feasible alternative to the default behavior of buffering and processing messages in memory in their entirety.

In WCF any receiving message is delivered only once the entire message has been received. What I mean here is that first message is buffered at the receiving side and once it is fully received it gets delivered to the receiving end. The main problem with this approach is that the receiver end is unresponsive while the message is getting buffered. So default way of message handling in WCF is ok for small size messages but for the large size messages, this approach is not good. So to overcome this problem Streaming in WCF come into action.

Source: c-sharpcorner.com

Q14: What is interoperability and how is it achieved with WCF services? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: When would you use Duplex WCF service? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: Will it make any difference if I change the operation contract of methods having no return value by [OperationContract(IsOneWay=true)]? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: Explain Binary vs MTOM vs Streaming in WCF? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: What is the difference between hosting WCF service on IIS, Windows Service and self-hosted app? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: Could we use WSHttpBinding with Request-CallBack (also called Duplex) exchange pattern? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: What is the main difference between Request-Response and Duplex in WCF Message Exchange Pattern? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: Should I use WCF or raw sockets? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: What replaces WCF in .Net Core? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 22 Important JavaScript/ES6/ES2015 Interview Questions | FullStack.Cafe

Q1: Could you explain the difference between ES5 and ES6 ⭐⭐⭐

Answer:

  • ECMAScript 5 (ES5): The 5th edition of ECMAScript, standardized in 2009. This standard has been implemented fairly completely in all modern browsers

  • ECMAScript 6 (ES6)/ ECMAScript 2015 (ES2015): The 6th edition of ECMAScript, standardized in 2015. This standard has been partially implemented in most modern browsers.

Here are some key differences between ES5 and ES6:

  • Arrow functions & string interpolation:
    Consider:
const greetings = (name) => {
      return `hello ${name}`;
}

and even:

const greetings = name => `hello ${name}`;
  • Const.
    Const works like a constant in other languages in many ways but there are some caveats. Const stands for ‘constant reference’ to a value. So with const, you can actually mutate the properties of an object being referenced by the variable. You just can’t change the reference itself.
const NAMES = [];
NAMES.push("Jim");
console.log(NAMES.length === 1); // true
NAMES = ["Steve", "John"]; // error
  • Block-scoped variables.
    The new ES6 keyword let allows developers to scope variables at the block level. Let doesn’t hoist in the same way var does.
  • Default parameter values Default parameters allow us to initialize functions with default values. A default is used when an argument is either omitted or undefined — meaning null is a valid value.
// Basic syntax
function multiply (a, b = 2) {
     return a * b;
}
multiply(5); // 10
  • ** Class Definition and Inheritance**
    ES6 introduces language support for classes (class keyword), constructors (constructor keyword), and the extend keyword for inheritance.

  • for-of operator
    The for...of statement creates a loop iterating over iterable objects.

  • Spread Operator For objects merging

const obj1 = { a: 1, b: 2 }
const obj2 = { a: 2, c: 3, d: 4}
const obj3 = {...obj1, ...obj2}
  • Promises
    Promises provide a mechanism to handle the results and errors from asynchronous operations. You can accomplish the same thing with callbacks, but promises provide improved readability via method chaining and succinct error handling.
const isGreater = (a, b) => {
  return new Promise ((resolve, reject) => {
    if(a > b) {
      resolve(true)
    } else {
      reject(false)
    }
    })
}
isGreater(1, 2)
  .then(result => {
    console.log('greater')
  })
 .catch(result => {
    console.log('smaller')
 })
  • Modules exporting & importing Consider module exporting:
const myModule = { x: 1, y: () => { console.log('This is ES5') }}
export default myModule;

and importing:

import myModule from './myModule';

Q2: What is IIFEs (Immediately Invoked Function Expressions)? ⭐⭐⭐

Answer: It’s an Immediately-Invoked Function Expression, or IIFE for short. It executes immediately after it’s created:

(function IIFE(){
	console.log( "Hello!" );
})();
// "Hello!"

This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.

Source: stackoverflow.com

Q3: When should I use Arrow functions in ES6? ⭐⭐⭐

Answer: I'm now using the following rule of thumb for functions in ES6 and beyond:

  • Use function in the global scope and for Object.prototype properties.
  • Use class for object constructors.
  • Use => everywhere else.

Why use arrow functions almost everywhere?

  • Scope safety: When arrow functions are used consistently, everything is guaranteed to use the same thisObject as the root. If even a single standard function callback is mixed in with a bunch of arrow functions there's a chance the scope will become messed up.
  • Compactness: Arrow functions are easier to read and write. (This may seem opinionated so I will give a few examples further on).
  • Clarity: When almost everything is an arrow function, any regular function immediately sticks out for defining the scope. A developer can always look up the next-higher function statement to see what the thisObject is.

Source: stackoverflow.com

Q4: What is the motivation for bringing Symbols to ES6? ⭐⭐⭐

Answer: Symbols are a new, special kind of object that can be used as a unique property name in objects. Using Symbol instead of string's allows different modules to create properties that don't conflict with one another. Symbols can also be made private, so that their properties can't be accessed by anyone who doesn't already have direct access to the Symbol.

Symbols are a new primitive. Just like the number, string, and boolean primitives, Symbol have a function which can be used to create them. Unlike the other primitives, Symbols do not have a literal syntax (e.g how string have '') - the only way to create them is with the Symbol constructor in the following way:

let symbol = Symbol();

In reality, Symbol's are just a slightly different way to attach properties to an object - you could easily provide the well-known Symbols as standard methods, just like Object.prototype.hasOwnProperty which appears in everything that inherits from Object.

Source: stackoverflow.com

Q5: What are the benefits of using spread syntax in ES6 and how is it different from rest syntax? ⭐⭐⭐

Answer: ES6's spread syntax is very useful when coding in a functional paradigm as we can easily create copies of arrays or objects without resorting to Object.create, slice, or a library function. This language feature is used often in Redux and rx.js projects.

function putDookieInAnyArray(arr) {
  return [...arr, 'dookie'];
}

const result = putDookieInAnyArray(['I', 'really', "don't", 'like']); // ["I", "really", "don't", "like", "dookie"]

const person = {
  name: 'Todd',
  age: 29,
};

const copyOfTodd = { ...person };

ES6's rest syntax offers a shorthand for including an arbitrary number of arguments to be passed to a function. It is like an inverse of the spread syntax, taking data and stuffing it into an array rather than unpacking an array of data, and it works in function arguments, as well as in array and object destructuring assignments.

function addFiveToABunchOfNumbers(...numbers) {
  return numbers.map(x => x + 5);
}

const result = addFiveToABunchOfNumbers(4, 5, 6, 7, 8, 9, 10); // [9, 10, 11, 12, 13, 14, 15]

const [a, b, ...rest] = [1, 2, 3, 4]; // a: 1, b: 2, rest: [3, 4]

const { e, f, ...others } = {
  e: 1,
  f: 2,
  g: 3,
  h: 4,
}; // e: 1, f: 2, others: { g: 3, h: 4 }

Source: github.com/yangshun

Q6: What are the differences between ES6 class and ES5 function constructors? ⭐⭐⭐

Answer: Let's first look at example of each:

// ES5 Function Constructor
function Person(name) {
  this.name = name;
}

// ES6 Class
class Person {
  constructor(name) {
    this.name = name;
  }
}

For simple constructors, they look pretty similar.

The main difference in the constructor comes when using inheritance. If we want to create a Student class that subclasses Person and add a studentId field, this is what we have to do in addition to the above.

// ES5 Function Constructor
function Student(name, studentId) {
  // Call constructor of superclass to initialize superclass-derived members.
  Person.call(this, name);

  // Initialize subclass's own members.
  this.studentId = studentId;
}

Student.prototype = Object.create(Person.prototype);
Student.prototype.constructor = Student;

// ES6 Class
class Student extends Person {
  constructor(name, studentId) {
    super(name);
    this.studentId = studentId;
  }
}

It's much more verbose to use inheritance in ES5 and the ES6 version is easier to understand and remember.

Source: github.com/yangshun

Q7: What's the difference between .call and .apply? ⭐⭐⭐

Answer: Both .call and .apply are used to invoke functions and the first parameter will be used as the value of this within the function. However, .call takes in comma-separated arguments as the next arguments while .apply takes in an array of arguments as the next argument. An easy way to remember this is C for call and comma-separated and A for apply and an array of arguments.

function add(a, b) {
  return a + b;
}

console.log(add.call(null, 1, 2)); // 3
console.log(add.apply(null, [1, 2])); // 3

Source: github.com/yangshun

Q8: Why should we use ES6 classes? ⭐⭐⭐

Answer: Some reasons you might choose to use Classes:

  • The syntax is simpler and less error-prone.
  • It's much easier (and again, less error-prone) to set up inheritance hierarchies using the new syntax than with the old.
  • class defends you from the common error of failing to use new with the constructor function (by having the constructor throw an exception if this isn't a valid object for the constructor).
  • Calling the parent prototype's version of a method is much simpler with the new syntax than the old (super.method() instead of ParentConstructor.prototype.method.call(this) or Object.getPrototypeOf(Object.getPrototypeOf(this)).method.call(this)).

Consider:

// **ES5**
var Person = function(first, last) {
    if (!(this instanceof Person)) {
        throw new Error("Person is a constructor function, use new with it");
    }
    this.first = first;
    this.last = last;
};

Person.prototype.personMethod = function() {
    return "Result from personMethod: this.first = " + this.first + ", this.last = " + this.last;
};

var Employee = function(first, last, position) {
    if (!(this instanceof Employee)) {
        throw new Error("Employee is a constructor function, use new with it");
    }
    Person.call(this, first, last);
    this.position = position;
};
Employee.prototype = Object.create(Person.prototype);
Employee.prototype.constructor = Employee;
Employee.prototype.personMethod = function() {
    var result = Person.prototype.personMethod.call(this);
    return result + ", this.position = " + this.position;
};
Employee.prototype.employeeMethod = function() {
    // ...
};

And the same with ES6 classes:

// ***ES2015+**
class Person {
    constructor(first, last) {
        this.first = first;
        this.last = last;
    }

    personMethod() {
        // ...
    }
}

class Employee extends Person {
    constructor(first, last, position) {
        super(first, last);
        this.position = position;
    }

    employeeMethod() {
        // ...
    }
}

Source: stackoverflow.com

Q9: What is the preferred syntax for defining enums in JavaScript? ⭐⭐⭐

Answer: Since 1.8.5 it's possible to seal and freeze the object, so define the above as:

var DaysEnum = Object.freeze({
    "monday": 1,
    "tuesday": 2,
    "wednesday": 3,
    ...
})

or

var DaysEnum = {
    "monday": 1,
    "tuesday": 2,
    "wednesday": 3,
    ...
}
Object.freeze(DaysEnum)

and voila! JS enums.

However, this doesn't prevent you from assigning an undesired value to a variable, which is often the main goal of enums:

let day = DaysEnum.tuesday
day = 298832342 // goes through without any errors

Source: stackoverflow.com

Q10: Explain the difference between Object.freeze() vs const ⭐⭐⭐

Answer: const and Object.freeze are two completely different things.

  • const applies to bindings ("variables"). It creates an immutable binding, i.e. you cannot assign a new value to the binding.
const person = {
    name: "Leonardo"
};
let animal = {
    species: "snake"
};
person = animal; // ERROR "person" is read-only
  • Object.freeze works on values, and more specifically, object values. It makes an object immutable, i.e. you cannot change its properties.
let person = {
    name: "Leonardo"
};
let animal = {
    species: "snake"
};
Object.freeze(person);
person.name = "Lima"; //TypeError: Cannot assign to read only property 'name' of object
console.log(person);

Source: stackoverflow.com

Q11: What is generator in JS? ⭐⭐⭐

Answer: Generators are functions which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances. Generator functions are written using the function* syntax. When called initially, generator functions do not execute any of their code, instead returning a type of iterator called a Generator. When a value is consumed by calling the generator's next method, the Generator function executes until it encounters the yield keyword.

The function can be called as many times as desired and returns a new Generator each time, however each Generator may only be iterated once.

function* makeRangeIterator(start = 0, end = Infinity, step = 1) {
    let iterationCount = 0;
    for (let i = start; i < end; i += step) {
        iterationCount++;
        yield i;
    }
    return iterationCount;
}

Source: stackoverflow.com

Q12: What is Hoisting in JavaScript? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: Explain the Prototype Design Pattern ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: What is the Temporal Dead Zone in ES6? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: When should you NOT use arrow functions in ES6? Name three or more cases. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: What are the actual uses of ES6 WeakMap? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: Explain why the following doesn't work as an IIFE. What needs to be changed to properly make it an IIFE? ⭐⭐⭐⭐

Details:

function foo(){ }();

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Could you compare usage of Module Pattern vs Constructor/Prototype pattern? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: What's the difference between ES6 Map and WeakMap? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: Can you give an example of a curry function and why this syntax offers an advantage? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: How to "deep-freeze" object in JavaScript? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: Compare Async/Await and Generators usage to achive same functionality ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 22+ Angular 6 Interview Questions to Stand Out in 2018 | FullStack.Cafe

Q1: What is difference between "declarations", "providers" and "import" in NgModule? ⭐⭐⭐

Answer:

  • imports makes the exported declarations of other modules available in the current module
  • declarations are to make directives (including components and pipes) from the current module available to other directives in the current module. Selectors of directives, components or pipes are only matched against the HTML if they are declared or imported.
  • providers are to make services and values known to DI. They are added to the root scope and they are injected to other services or directives that have them as dependency.

A special case for providers are lazy loaded modules that get their own child injector. providers of a lazy loaded module are only provided to this lazy loaded module by default (not the whole application as it is with other modules).

Source: medium.com

Q2: What is AOT? ⭐⭐⭐

Answer: The Angular Ahead-of-Time compiler pre-compiles application components and their templates during the build process. Apps compiled with AOT launch faster for several reasons.

  • Application components execute immediately, without client-side compilation.
  • Templates are embedded as code within their components so there is no client-side request for template files.
  • You don't download the Angular compiler, which is pretty big on its own.
  • The compiler discards unused Angular directives that a tree-shaking tool can then exclude.

Source: stackoverflow.com

Q3: Explain the difference between "Constructor" and "ngOnInit" ⭐⭐⭐

Answer:

  • The Constructor is a default method of the class that is executed when the class is instantiated and ensures proper initialization of fields in the class and its subclasses.
  • ngOnInit is a life cycle hook called by Angular to indicate that Angular is done creating the component. We have to import OnInit in order to use like this (actually implementing OnInit is not mandatory but considered good practice).

Mostly we use ngOnInit for all the initialization/declaration and avoid stuff to work in the constructor. The constructor should only be used to initialize class members but shouldn't do actual "work".

Source: stackoverflow.com

Q4: What's new in Angular 6 and why shall we upgrade to it? ⭐⭐⭐

Answer:

  • Angular Elements - Angular Elements is a project that lets you wrap your Angular components as Web Components and embed them in a non-Angular application.
  • New Rendering Engine: Ivy - increases in speed and decreases in application size.
  • Tree-shakeable providers - a new, recommended, way to register a provider, directly inside the @Injectable() decorator, using the new providedIn attribute
  • RxJS 6 - Angular 6 now uses RxJS 6 internally, and requires you to update your application also. RxJS released a library called rxjs-compat, that allows you to bump RxJS to version 6.0 even if you, or one of the libraries you’re using, is still using one of the “old” syntaxes.
  • ElementRef<T> - in Angular 5.0 or older, is that the said ElementRef had its nativeElement property typed as any. In Angular 6.0, you can now type ElementRef more strictly.
  • Animations - The polyfill web-animations-js is not necessary anymore for animations in Angular 6.0, except if you are using the AnimationBuilder.
  • i18n - possibility to have “runtime i18n”, without having to build the application once per locale.

Source: ninja-squad.com

Q5: Why would you use renderer methods instead of using native element methods? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q6: What is Zone in Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q7: Why would you use lazy loading modules in Angular app? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q8: What are the lifecycle hooks for components and directives? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q9: How would you insert an embedded view from a prepared TemplateRef? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q10: How to detect a route change in Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: What does a just-in-time (JIT) compiler do (in general)? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: How do you create application to use scss? What changed for Angular 6? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: What is ngUpgrage? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: What is Reactive programming and how does it relate to Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: Name some security best practices in Angular ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: Could I use jQuery with Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: What is the Angular equivalent to an AngularJS "$watch"? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation. Explain the difference. ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: Do you know how you can run angularJS and angular side by side? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: Could you provide some particular examples of using ngZone? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: Why angular uses url segment? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: When to use query parameters versus matrix parameters? ⭐⭐⭐⭐⭐

Details:

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 23 Advanced JavaScript Interview Questions | FullStack.Cafe

Q1: Explain equality in JavaScript ⭐

Answer: JavaScript has both strict and type–converting comparisons:

  • Strict comparison (e.g., ===) checks for value equality without allowing coercion
  • Abstract comparison (e.g. ==) checks for value equality with coercion allowed
var a = "42";
var b = 42;

a == b;			// true
a === b;		// false

Some simple equalityrules:

  • If either value (aka side) in a comparison could be the true or false value, avoid == and use ===.
  • If either value in a comparison could be of these specific values (0, "", or [] -- empty array), avoid == and use ===.
  • In all other cases, you're safe to use ==. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.

Q2: Provide some examples of non-bulean value coercion to a boolean one ⭐⭐⭐

Answer: The question is when a non-boolean value is coerced to a boolean, does it become true or false, respectively?

The specific list of "falsy" values in JavaScript is as follows:

  • "" (empty string)
  • 0, -0, NaN (invalid number)
  • null, undefined
  • false

Any value that's not on this "falsy" list is "truthy." Here are some examples of those:

  • "hello"
  • 42
  • true
  • [ ], [ 1, "2", 3 ] (arrays)
  • { }, { a: 42 } (objects)
  • function foo() { .. } (functions)

Q3: What is IIFEs (Immediately Invoked Function Expressions)? ⭐⭐⭐

Answer: It’s an Immediately-Invoked Function Expression, or IIFE for short. It executes immediately after it’s created:

(function IIFE(){
	console.log( "Hello!" );
})();
// "Hello!"

This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.

Source: stackoverflow.com

Q4: When should I use Arrow functions in ES6? ⭐⭐⭐

Answer: I'm now using the following rule of thumb for functions in ES6 and beyond:

  • Use function in the global scope and for Object.prototype properties.
  • Use class for object constructors.
  • Use => everywhere else.

Why use arrow functions almost everywhere?

  • Scope safety: When arrow functions are used consistently, everything is guaranteed to use the same thisObject as the root. If even a single standard function callback is mixed in with a bunch of arrow functions there's a chance the scope will become messed up.
  • Compactness: Arrow functions are easier to read and write. (This may seem opinionated so I will give a few examples further on).
  • Clarity: When almost everything is an arrow function, any regular function immediately sticks out for defining the scope. A developer can always look up the next-higher function statement to see what the thisObject is.

Source: stackoverflow.com

Q5: What are the differences between ES6 class and ES5 function constructors? ⭐⭐⭐

Answer: Let's first look at example of each:

// ES5 Function Constructor
function Person(name) {
  this.name = name;
}

// ES6 Class
class Person {
  constructor(name) {
    this.name = name;
  }
}

For simple constructors, they look pretty similar.

The main difference in the constructor comes when using inheritance. If we want to create a Student class that subclasses Person and add a studentId field, this is what we have to do in addition to the above.

// ES5 Function Constructor
function Student(name, studentId) {
  // Call constructor of superclass to initialize superclass-derived members.
  Person.call(this, name);

  // Initialize subclass's own members.
  this.studentId = studentId;
}

Student.prototype = Object.create(Person.prototype);
Student.prototype.constructor = Student;

// ES6 Class
class Student extends Person {
  constructor(name, studentId) {
    super(name);
    this.studentId = studentId;
  }
}

It's much more verbose to use inheritance in ES5 and the ES6 version is easier to understand and remember.

Source: github.com/yangshun

Q6: Explain Function.prototype.bind. ⭐⭐⭐

Answer: Taken word-for-word from MDN:

The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.

In my experience, it is most useful for binding the value of this in methods of classes that you want to pass into other functions. This is frequently done in React components.

Source: github.com/yangshun

Q7: What's a typical use case for anonymous functions? ⭐⭐⭐

Answer: They can be used in IIFEs to encapsulate some code within a local scope so that variables declared in it do not leak to the global scope.

(function() {
  // Some code here.
})();

As a callback that is used once and does not need to be used anywhere else. The code will seem more self-contained and readable when handlers are defined right inside the code calling them, rather than having to search elsewhere to find the function body.

setTimeout(function() {
  console.log('Hello world!');
}, 1000);

Arguments to functional programming constructs or Lodash (similar to callbacks).

const arr = [1, 2, 3];
const double = arr.map(function(el) {
  return el * 2;
});
console.log(double); // [2, 4, 6]

Source: github.com/yangshun

Q8: Explain the difference between Object.freeze() vs const ⭐⭐⭐

Answer: const and Object.freeze are two completely different things.

  • const applies to bindings ("variables"). It creates an immutable binding, i.e. you cannot assign a new value to the binding.
const person = {
    name: "Leonardo"
};
let animal = {
    species: "snake"
};
person = animal; // ERROR "person" is read-only
  • Object.freeze works on values, and more specifically, object values. It makes an object immutable, i.e. you cannot change its properties.
let person = {
    name: "Leonardo"
};
let animal = {
    species: "snake"
};
Object.freeze(person);
person.name = "Lima"; //TypeError: Cannot assign to read only property 'name' of object
console.log(person);

Source: stackoverflow.com

Q9: What is generator in JS? ⭐⭐⭐

Answer: Generators are functions which can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances. Generator functions are written using the function* syntax. When called initially, generator functions do not execute any of their code, instead returning a type of iterator called a Generator. When a value is consumed by calling the generator's next method, the Generator function executes until it encounters the yield keyword.

The function can be called as many times as desired and returns a new Generator each time, however each Generator may only be iterated once.

function* makeRangeIterator(start = 0, end = Infinity, step = 1) {
    let iterationCount = 0;
    for (let i = start; i < end; i += step) {
        iterationCount++;
        yield i;
    }
    return iterationCount;
}

Source: stackoverflow.com

Q10: When should we use generators in ES6? ⭐⭐⭐

Answer: To put it simple, generator has two features:

  • one can choose to jump out of a function and let outer code to determine when to jump back into the function.
  • the control of asynchronous call can be done outside of your code

The most important feature in generators — we can get the next value in only when we really need it, not all the values at once. And in some situations it can be very convenient.

Source: stackoverflow.com

Q11: Explain what is hoisting in Javascript ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: What will be the output of the following code? ⭐⭐⭐⭐

Details:

var output = (function(x) {
  delete x;
  return x;
})(0);

console.log(output);

Answer: Read Full Answer on 👉 FullStack.Cafe

Q13: What will be the output of the following code? ⭐⭐⭐⭐

Details:

var Employee = {
  company: 'xyz'
}
var emp1 = Object.create(Employee);
delete emp1.company
console.log(emp1.company);

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: Explain the Prototype Design Pattern ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: What is the Temporal Dead Zone in ES6? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: Can you describe the main difference between a .forEach loop and a .map() loop and why you would pick one versus the other? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: What's the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Describe the Revealing Module Pattern design pattern ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: What's the difference between ES6 Map and WeakMap? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: Is JavaScript a pass-by-reference or pass-by-value language? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: How to "deep-freeze" object in JavaScript? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: In JavaScript, why is the “this” operator inconsistent? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: Compare Async/Await and Generators usage to achive same functionality ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 26 Top Angular 8 Interview Questions To Learn in 2019 | FullStack.Cafe

Q1: Explain the difference between Promise and Observable in Angular? ⭐⭐⭐

Answer: Promises:

  • return a single value
  • not cancellable
  • more readable code with try/catch and async/await

Observables:

  • work with multiple values over time
  • cancellable
  • support map, filter, reduce and similar operators
  • use Reactive Extensions (RxJS)
  • an array whose items arrive asynchronously over time

Source: stackoverflow.com

Q2: Why should ngOnInit be used, if we already have a constructor? ⭐⭐⭐

Answer:

  • The Constructor is a default method of the class that is executed when the class is instantiated and ensures proper initialization of fields in the class and its subclasses.

  • ngOnInit is a life cycle hook called by Angular2 to indicate that Angular is done creating the component.

Mostly we use ngOnInit for all the initialization/declaration and avoid stuff to work in the constructor. The constructor should only be used to initialize class members but shouldn't do actual "work". So you should use constructor() to setup Dependency Injection and not much else. ngOnInit() is better place to "start" - it's where/when components' bindings are resolved.

Source: medium.com

Q3: What is AOT? ⭐⭐⭐

Answer: The Angular Ahead-of-Time compiler pre-compiles application components and their templates during the build process. Apps compiled with AOT launch faster for several reasons.

  • Application components execute immediately, without client-side compilation.
  • Templates are embedded as code within their components so there is no client-side request for template files.
  • You don't download the Angular compiler, which is pretty big on its own.
  • The compiler discards unused Angular directives that a tree-shaking tool can then exclude.

Source: stackoverflow.com

Q4: What is the use of codelyzer? ⭐⭐⭐

Answer: All enterprise applications follows a set of coding conventions and guidelines to maintain code in better way. Codelyzer is an open source tool to run and check whether the pre-defined coding guidelines has been followed or not. Codelyzer does only static code analysis for angular and typescript project.

Codelyzer runs on top of tslint and its coding conventions are usually defined in tslint.json file. Codelyzer can be run via angular cli or npm directly. Editors like Visual Studio Code and Atom also supports codelyzer just by doing a basic settings.

Source: pankajagarwal.in

Q5: What is the purpose of Wildcard route? ⭐⭐⭐

Answer: If the URL doesn't match any predefined routes then it causes the router to throw an error and crash the app. In this case, you can use wildcard route. A wildcard route has a path consisting of two asterisks to match every URL.

For example, you can define PageNotFoundComponent for wildcard route as below

{ path: '**', component: PageNotFoundComponent }

Source: github.com/sudheerj

Q6: What are custom elements? ⭐⭐⭐

Answer: Custom elements (or Web Components) are a Web Platform feature which extends HTML by allowing you to define a tag whose content is created and controlled by JavaScript code. The browser maintains a CustomElementRegistry of defined custom elements, which maps an instantiable JavaScript class to an HTML tag. Currently this feature is supported by Chrome, Firefox, Opera, and Safari, and available in other browsers through polyfills.

Source: github.com/sudheerj

Q7: What are the utility functions provided by RxJS? ⭐⭐⭐

Answer: The RxJS library also provides below utility functions for creating and working with observables.

  1. Converting existing code for async operations into observables
  2. Iterating through the values in a stream
  3. Mapping values to different types
  4. Filtering streams
  5. Composing multiple streams

Source: github.com/sudheerj

Q8: What is subscribing? ⭐⭐⭐

Answer: An Observable instance begins publishing values only when someone subscribes to it. So you need to subscribe by calling the subscribe() method of the instance, passing an observer object to receive the notifications.

Let's take an example of creating and subscribing to a simple observable, with an observer that logs the received message to the console.

    Creates an observable sequence of 5 integers, starting from 1
    const source = range(1, 5);

    // Create observer object
    const myObserver = {
      next: x => console.log('Observer got a next value: ' + x),
      error: err => console.error('Observer got an error: ' + err),
      complete: () => console.log('Observer got a complete notification'),
    };

    // Execute with the observer object and Prints out each item
    myObservable.subscribe(myObserver);
    // => Observer got a next value: 1
    // => Observer got a next value: 2
    // => Observer got a next value: 3
    // => Observer got a next value: 4
    // => Observer got a next value: 5
    // => Observer got a complete notification

Source: github.com/sudheerj

Q9: What's new in Angular 8? ⭐⭐⭐

Answer: This release is mostly about Ivy and the possibility to give it a try, but it also includes a few features and breaking changes, namely:

  • Differential loading - with differential loading, two bundles are created when building for production: a bundle for modern browsers that support ES2015+ and a bundle for older browsers that only support the ES5 version of JavaScript
  • TypeScript 3.4 support
  • Ivy - it is the new compiler/runtime of Angular. It will enable very cool features in the future, but it is currently focused on not breaking existing applications.
  • Bazel support - it is a build tool developed and massively used by Google, as it can build pretty much any language.
  • Lazy-loading with import() syntax
// from
loadChildren: './admin/admin.module#AdminModule'
// to
loadChildren: () => import('./races/races.module').then(m => m.RacesModule)
  • To help people migrating from AngularJS, a bunch of things have been added to the location services in Angular
  • The service worker registration has a new option that allows to specify when the registration should take place.
  • @angular/http has been removed from 8.0, after being replaced by @angular/common/http in 4.3 and officially deprecated in 5.0,

Source: blog.ninja-squad.com

Q10: Angular 8: What is Bazel? ⭐⭐⭐

Answer: Google open sourced the software responsible for building most of its projects under the name Bazel. Bazel is a powerful tool which can keep track of the dependencies between different packages and build targets.

Some of the features of Bazel are:

  • It has a smart algorithm for determining the build dependencies - based on the dependency graph of a project, Bazel determines which targets it can build in parallel
  • Bazel is independent of the tech stack. We can build anything we want with it using the same interface. For example, there are plugins for Java, Go, TypeScript, JavaScript, and more

Source: blog.mgechev.com

Q11: Angular 8: What is Angular Ivy? ⭐⭐⭐

Answer: A big part of Angular is its compiler: it takes all your HTML and generates the necessary JS code. This compiler (and the runtime) has been completely rewritten over the last year, and this is what Ivy is about. The last rewrite was done in Angular 4.0.

Ivy is a complete rewrite of the compiler (and runtime) in order to:

  • reach better build times (with a more incremental compilation)
  • reach better build sizes (with a generated code more compatible with tree-shaking)
  • unlock new potential features (metaprogramming or higher order components, lazy loading of component instead of modules, a new change detection system not based on zone.js…)

Source: blog.ninja-squad.com

Q12: Angular 8: Explain Lazy Loading in Angular 8? ⭐⭐⭐

Answer: Lazy loading is one of the most useful concepts of Angular Routing and brings down the size of large files. This is done by lazily loading the files that are required occasionally.

Angular 8 comes up with support for dynamic imports in our router configuration. This means that we use the import statement for lazy loading the module and this will be understood by the IDEs, webpack, etc.

Angular 7:

{path: ‘user’, loadChildren: ./users/user.module#UserModule’}

Angular 8:

{path: ‘user’, loadChildren: () => import(./users/user.module’).then(m => m.UserModule)};

New with Angular 8, loadChildren expects a function that uses the dynamic import syntax to import your lazy-loaded module only when it’s needed. As you can see, the dynamic import is promise-based and gives you access to the module, where the module’s class can be called.

Source: dev.to

Q13: How to detect a route change in Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q14: Are there any pros/cons (especially performance-wise) in using local storage to replace cookie functionality? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q15: What is Zone in Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: What does a just-in-time (JIT) compiler do (in general)? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: What is ngUpgrage? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: What is incremental DOM? How is it different from virtual DOM? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: Angular 8: Why we should use Bazel for Angular builds? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: Explain the purpose of Service Workers in Angular ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: What is the Angular equivalent to an AngularJS "$watch"? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation. Explain the difference. ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: Why did the Google team go with incremental DOM instead of virtual DOM? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: Why Incremental DOM is Tree Shakable? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Angular 8: How does Ivy affect the (Re)build time? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: Angular 8: What are some changes in Location module? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 29 Essential Blockchain Interview Questions You Will Suck On | FullStack.Cafe

Q1: What is blockchain? ⭐

Answer: Blockchain is a secure distributed ledger (data structure or database) that maintains a continuously growing list of ordered records, called “blocks”, that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.

By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".

Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority.

Source: en.wikipedia.org

Q2: Explain the common structure of blockchains ⭐⭐

Answer: Blockchains are composed of three core parts:

  • Block: A list of transactions recorded into a ledger over a given period. The size, period, and triggering event for blocks is different for every blockchain.
  • Chain: A hash that links one block to another, mathematically “chaining” them together.
  • Network: The network is composed of “full nodes.” Think of them as the computer running an algorithm that is securing the network. Each node contains a complete record of all the transactions that were ever recorded in that blockchain.

Source: dummies.com

Q3: What is the blockchain data structure? ⭐⭐

Answer: Basically the blockchain data structure is explained as a back-linked record of blocks of transactions, which is ordered. It can be saved as a file or in a plain database. Each block can be recognized by a hash, created utilizing the SHA256 cryptographic hash algorithm on the header of the block. Each block mentions a former block, also identified as the parent block, in the “previous block hash” field, in the block header.

Source: cryptoticker.io

Q4: What is the Genesis Block? ⭐⭐

Answer: The **first block in any blockchain **is termed the genesis block. If you start at any block and follow the chain backwards chronologically, you will arrive at the genesis block. The genesis block is statically encoded within the client software, that it cannot be changed. Every node can identify the genesis block’s hash and structure, the fixed time of creation, and the single transactions within. Thus every node has a secure “root” from which is possible to build a trusted blockchain on.

Source: linkedin.com

Q5: What is the purpose of a blockchain node? ⭐⭐

Answer: A blockchain exists out of blocks of data. These blocks of data are stored on nodes (compare it to small servers). Nodes can be any kind of device (mostly computers, laptops or even bigger servers). Nodes form the infrastructure of a blockchain.

All nodes on a blockchain are connected to each other and they constantly exchange the latest blockchain data with each other so all nodes stay up to date. They store, spread and preserve the blockchain data, so theoretically a blockchain exists on nodes.

A full node is basically a device (like a computer) that contains a full copy of the transaction history of the blockchain.

Source: lisk.io

Q6: What is proof-of-work? ⭐⭐

Answer: A proof of work is a piece of data which is difficult (costly, time-consuming) to produce but easy for others to verify and which satisfies certain requirements. Producing a proof of work can be a random process with low probability so that a lot of trial and error is required on average before a valid proof of work is generated. Difficulty is a measure of how difficult it is to find a hash below a given target.

Source: en.bitcoin.it

Q7: What is deterministic behavior? ⭐⭐

Answer: If A + B = C, then no matter what the circumstances, A+B will always be equal to C. That is called deterministic behavior.

Hash functions are deterministic, meaning A’s hash will always be H(A).

Source: blockgeeks.com

Q8: Why does Blockchain need coins or tokens? ⭐⭐

Answer: Tokens/Coins are used as a medium of exchange between the states. They are digital assets built in to perform a specific function within a blockchain.

When someone does a transaction, there is a change of state, and coins are moved from one address to another address. Apart from that, transactions contain some additional data; this data can be mutated through the change of state. For this reason, blockchains need coins or tokens to incentivize the participants to join their networks.

Source: mindmajix.com

Q9: What is Merkle Trees? ⭐⭐⭐

Answer: Merkle trees are a fundamental part of blockchain technology. A merkle tree is a structure that allows for efficient and secure verification of content in a large body of data.

A Merkle tree summarizes all the transactions in a block by producing a digital fingerprint of the entire set of transactions, thereby enabling a user to verify whether or not a transaction is included in a block.

Merkle trees are created by repeatedly hashing pairs of nodes until there is only one hash left (this hash is called the Root Hash, or the Merkle Root). They are constructed from the bottom up, from hashes of individual transactions (known as Transaction IDs). Hashing is usually conducted using the SHA-2 cryptographic hash function, though other functions can also be used.

Source: hackernoon.com

Q10: What are some advantages of using Merke Trees? ⭐⭐⭐

Answer: Using a Merkle tree can significantly reduce the amount of data that a trusted authority has to maintain for verification purposes. It separates the validation of the data from the data itself.

Merkle trees have three major benefits:

  1. They provide a means to prove the integrity and validity of data
  2. They require little memory or disk space as the proofs are computationally easy and fast
  3. Their proofs and management only require tiny amounts of information to be transmitted across networks

The ability to prove that a log is complete and consistent is essential to blockchain technology and the general ledger concept. Merkle trees help verify that later versions of a log include everything from an earlier version and that all data is recorded and presented in chronological order.

Source: hackernoon.com

Q11: Explain what do nodes do? ⭐⭐⭐

Answer: When a miner attempts to add a new block of transactions to the blockchain, it broadcasts the block to all the nodes on the network. Based on the block’s legitimacy (validity of signature and transactions), nodes can accept or reject the block. When a node accepts a new block of transactions, it saves and stores it on top of the rest of the blocks it already has stored. In short, here is what nodes do:

  • Nodes check if a block of transactions is valid and accept or reject it.
  • Nodes save and store blocks of transactions (storing blockchain transaction history).
  • Nodes broadcast and spread this transaction history to other nodes that may need to synchronize with the blockchain (need to be updated on transaction history).

Source: medium.com

Q12: Why is the blockchain immutable? ⭐⭐⭐

Answer: Altering a single block requires a new signature for every other block that comes after it all the way to the end of the chain. This is considered to be near impossible. Why?

Let’s say a corrupt miner has altered a block of transactions and is now trying to calculate new signatures for the subsequent blocks in order to have the rest of the network accept his change. The problem for him is, the rest of the network is also calculating new signatures for new blocks. The corrupt miner will have to calculate new signatures for these blocks too as they are being added to the end of the chain. After all, he needs to keep all of the blocks linked, including the new ones constantly being added. Unless the miner has more computational power than the rest of the network combined, he will never catch up with the rest of the network finding signatures.

Millions of users are mining on the blockchain, and therefore it can be assumed that a single bad actor or entity on the network will never have more computational power than the rest of the network combined, meaning the network will never accept any changes on the blockchain, making the blockchain immutable.

Source: medium.com

Q13: What is mining difficulty? ⭐⭐⭐

Answer: Mining difficulty is the degree that determines how hard it is for miners in terms of hashing power (and thus also time) to find an eligible hash aka signature for their block (a block of transactions needs an eligible hash to be verified and added to the blockchain). On the Bitcoin blockchain, miners try to find an eligible hash by hashing random numbers.

A block of transactions will only be accepted by the rest of the network if it has a signature (hash) that meets certain requirements (in example of Bitcoin, the signature needs to start with a certain number of zeroes). In order to find this signature, miners are spending computational power (hashing power) to perform a set of pre-determined operations on random numbers untill they find a number that leads to an output number that meets the requirements.

Finding an output that starts with only one zero is much easier (generally more common) than finding an output number that starts with five consecutive zeroes (this is pretty rare so it would take much more time to find a number that leads to such output).

For example block 100 (back in 2009) only required a signature that started with eight consecutive zeroes, whereas the last recent block (block 542865) needed a signature that started with at least 18 consecutive zeroes.

Source: medium.com

Q14: Explain why there is a fixed supply of bitcoins? ⭐⭐⭐

Answer: There is a fixed supply of bitcoins. There will never be more than 21 million bitcoins. Bitcoins are created each time a user discovers a new block. The rate of block creation is adjusted every 2016 blocks to aim for a constant two week adjustment period (equivalent to 6 per hour).

The number of bitcoins generated per block is set to decrease geometrically, with a 50% reduction every 210,000 blocks, or approximately four years. The result is that the number of bitcoins in existence will not exceed slightly less than 21 million.

Source: en.bitcoin.it

Q15: What is DApp or Decentralised Application? ⭐⭐⭐

Answer: A decentralized application (DApp, dApp, Dapp, or dapp) is a computer application that runs on a distributed computing system.

Decentralized applications don‘t necessarily need to run on top of a blockchain network. Tor, BitTorrent, Popcorn Time, BitMessage, are examples for decentralized applications that run on a P2P network, but not on a blockchain – which is a special kind of P2P network.

DApps have been mostly popularized by distributed ledger technologies (DLT), namely the Ethereum Blockchain, where DApps are often referred to as smart contracts. Its backend code runs on a decentralized peer-to-peer network, and all records of the applicationʼs operation are stored on a blockchain. In most cases, the entire code base is Open Source.

Source: blockchainhub.net

Q16: What is a trapdoor function, and why is it needed in blockchain development? ⭐⭐⭐

Answer: A trapdoor function is a function that is easy to compute in one direction but difficult to compute in the opposite direction unless you have special information. Trapdoor functions are essential for public key encryption—that’s why they are commonly used in blockchain development to represent the ideas of addresses and private keys.

Source: toptal.com

Q17: Explain why a blockchain needs tokens to operate ⭐⭐⭐

Answer: Coins/tokens are used to implement changes between states. When somebody does a transaction, this is a change of state, and coins are moved from one address to another. Apart from that, transactions can contain additional data, and a change of state is used to mutate data—the only way to do this in an immutable-by-definition blockchain.

Technically, a blockchain doesn’t need coins for its essential operations, but without them, some other way needs to be introduced to manage states of the chain and to verify transactions.

Source: toptal.com

Q18: How do verifiers check if a block is valid? ⭐⭐⭐

Answer: Every full node on the network does block verification. When a new block is announced, every node that receives it does a list of checks. The two most important checks are of proof of work (if a block provides enough work to be included into chain) and of the validity of all transactions (each transaction must be valid).

Source: toptal.com

Q19: What is RSA algorithm? ⭐⭐⭐

Answer: RSA (Rivest–Shamir–Adleman) is an algorithm used by modern computers to encrypt and decrypt messages. It is an asymmetric cryptographic algorithm. Asymmetric means that there are two different keys. This is also called public key cryptography, because one of the keys can be given to anyone. The other key must be kept private. The algorithm is based on the fact that finding the factors of a large composite number is difficult.

RSA involves a public key and private key. The public key can be known to everyone; it is used to encrypt messages. Messages encrypted using the public key can only be decrypted with the private key.

Source: simple.wikipedia.org

Q20: What is a smart contract? ⭐⭐⭐

Answer: A smart contract is a computer protocol intended to digitally facilitate, verify, or enforce the negotiation or performance of a contract. Smart contracts allow the performance of credible transactions without third parties. These transactions are trackable and irreversible.

The aim of smart contracts is to provide security that is superior to traditional contract law and to reduce other transaction costs associated with contracting. Various cryptocurrencies have implemented types of smart contracts.

Source: en.wikipedia.org

Q21: What is a 51% attack? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: What is a stealth address? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: Explain what is target hash? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: What Is a Proof of Stake? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: What is the difference between PoW and PoS? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: What is off-chain transaction? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: Why is Git not considered a “block chain”? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: What are miners really solving? ⭐⭐⭐⭐⭐

Details: As with mining, what are miners really solving? I read they are solving hashes, but what does that really mean.

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: Is it possible to brute force bitcoin address creation in order to steal money? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 30 Best MongoDB Interview Questions and Answers (2018 Update) | FullStack.Cafe

Q1: Explain what is MongoDB? ⭐

Answer: MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. It's Key Features are:

  • Document Oriented and NoSQL database.
  • Supports Aggregation
  • Uses BSON format
  • Sharding (Helps in Horizontal Scalability)
  • Supports Ad Hoc Queries
  • Schema Less
  • Capped Collection
  • Indexing (Any field in MongoDB can be indexed)
  • MongoDB Replica Set (Provides high availability)
  • Supports Multiple Storage Engines

Source: mongodb.com

Q2: What Is Replication In MongoDB? ⭐⭐

Answer: Replication is the process of synchronizing data across multiple servers. Replication provides redundancy and increases data availability. With multiple copies of data on different database servers, replication protects a database from the loss of a single server. Replication also allows you to recover from hardware failure and service interruptions.

Source: interviewbubble.com

Q3: How is data stored in MongoDB? ⭐⭐

Answer: Data in MongoDB is stored in BSON documents – JSON-style data structures. Documents contain one or more fields, and each field contains a value of a specific data type, including arrays, binary data and sub-documents. Documents that tend to share a similar structure are organized as collections. It may be helpful to think of documents as analogous to rows in a relational database, fields as similar to columns, and collections as similar to tables.

The advantages of using documents are:

  • Documents (i.e. objects) correspond to native data types in many programming languages.
  • Embedded documents and arrays reduce need for expensive joins.
  • Dynamic schema supports fluent polymorphism.

Source: mongodb.com

Q4: What are Indexes in MongoDB? ⭐⭐

Answer: Indexes support the efficient execution of queries in MongoDB. Without indexes, MongoDB must perform a collection scan, i.e. scan every document in a collection, to select those documents that match the query statement. If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect.

Source: tutorialspoint.com

Q5: Can you create an index on an array field in MongoDB? If yes, what happens in this case? ⭐⭐

Answer: Yes. An array field can be indexed in MongoDB. In this case, MongoDB would index each value of the array so you can query for individual items:

> db.col1.save({'colors': ['red','blue']})
> db.col1.ensureIndex({'colors':1})

> db.col1.find({'colors': 'red'})
{ "_id" : ObjectId("4ccc78f97cf9bdc2a2e54ee9"), "colors" : [ "red", "blue" ] }
> db.col1.find({'colors': 'blue'})
{ "_id" : ObjectId("4ccc78f97cf9bdc2a2e54ee9"), "colors" : [ "red", "blue" ] }

Source: stackoverflow.com

Q6: What is Aggregation in MongoDB? ⭐⭐⭐

Answer: Aggregations operations process data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result. MongoDB provides three ways to perform aggregation:

  • the aggregation pipeline,
  • the map-reduce function,
  • and single purpose aggregation methods and commands.

Source: tutorialspoint.com

Q7: How to query MongoDB with %like%? ⭐⭐⭐

Details: I want to query something as SQL's like query:

select * 
from users 
where name like '%m%'

How to do the same in MongoDB?

Answer:

db.users.find({name: /a/})  //like '%a%'
db.users.find({name: /^pa/}) //like 'pa%'
db.users.find({name: /ro$/}) //like '%ro'

Or using Mongoose:

db.users.find({'name': {'$regex': 'sometext'}})

Source: stackoverflow.com

Q8: How do I perform the SQL JOIN equivalent in MongoDB? ⭐⭐⭐

Answer: Mongo is not a relational database, and the devs are being careful to recommend specific use cases for $lookup, but at least as of 3.2 doing join is now possible with MongoDB. The new $lookup operator added to the aggregation pipeline is essentially identical to a left outer join:

{
   $lookup:
     {
       from: <collection to join>,
       localField: <field from the input documents>,
       foreignField: <field from the documents of the "from" collection>,
       as: <output array field>
     }
}

Source: stackoverflow.com

Q9: What is the difference b/w MongoDB and CouchDB? ⭐⭐⭐

Answer: MongoDB and CouchDB both are the great example of open source NoSQL database. Both are document oriented databases. Although both stores data but there is a lot of difference between them in terms of implementation of their data models, interfaces, object storage and replication methods etc.

Source: medium.com/@hub4tech

Q10: What are NoSQL databases? What are the different types of NoSQL databases? ⭐⭐⭐

Answer: A NoSQL database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases (like SQL, Oracle, etc.).

Types of NoSQL databases:

  • Document Oriented
  • Key Value
  • Graph
  • Column Oriented

Source: interviewbubble.com

Q11: Explain the structure of ObjectID in MongoDB ⭐⭐⭐

Answer: ObjectIds are small, likely unique, fast to generate, and ordered. ObjectId values consist of 12 bytes, where the first four bytes are a timestamp that reflect the ObjectId’s creation. Specifically:

  • a 4-byte value representing the seconds since the Unix epoch,
  • a 5-byte random value, and
  • a 3-byte counter, starting with a random value. In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. If an inserted document omits the _id field, the MongoDB driver automatically generates an ObjectId for the _id field.

Source: mongodb.com

Q12: What is a covered query in MongoDB? ⭐⭐⭐

Answer: A covered query is the one in which:

  • fields used in the query are part of an index used in the query, and
  • the fields returned in the results are in the same index

Source: tutorialspoint.com

Q13: Find objects between two dates MongoDB ⭐⭐⭐

Answer:

db.CollectionName.find({"whenCreated": {
    '$gte': ISODate("2018-03-06T13:10:40.294Z"),
    '$lt': ISODate("2018-05-06T13:10:40.294Z")
}});

Source: stackoverflow.com

Q14: What is oplog? ⭐⭐⭐

Answer: The oplog (operations log) is a special capped collection that keeps a rolling record of all operations that modify the data stored in your databases. MongoDB applies database operations on the primary and then records the operations on the primary’s oplog. The secondary members then copy and apply these operations in an asynchronous process.

Source: tutorialspoint.com

Q15: Does MongoDB support ACID transaction management and locking functionalities? ⭐⭐⭐

Answer: ACID stands that any update is:

  • Atomic: it either fully completes or it does not
  • Consistent: no reader will see a "partially applied" update
  • Isolated: no reader will see a "dirty" read
  • Durable: (with the appropriate write concern)

Historically MongoDB does not support default multi-document ACID transactions (multiple-document updates that can be rolled back and are ACID-compliant). However, MongoDB provides atomic operation on a single document. MongoDB 4.0 will add support for multi-document transactions, making it the only database to combine the speed, flexibility, and power of the document model with ACID data integrity guarantees.

Source: tutorialspoint.com

Q16: What is Sharding in MongoDB? Explain. ⭐⭐⭐

Answer: Sharding is a method for storing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.

Source: tutorialspoint.com

Q17: Should I normalize my data before storing it in MongoDB? ⭐⭐⭐

Answer: It depends from your goals. Normalization will provide an update efficient data representation. Denormalization will make data reading efficient.

In general, use embedded data models (denormalization) when:

  • you have “contains” relationships between entities.
  • you have one-to-many relationships between entities. In these relationships the “many” or child documents always appear with or are viewed in the context of the “one” or parent documents.

In general, use normalized data models:

  • when embedding would result in duplication of data but would not provide sufficient read performance advantages to outweigh the implications of the duplication.
  • to represent more complex many-to-many relationships.
  • to model large hierarchical data sets.

Also normalizing your data like you would with a relational database is usually not a good idea in MongoDB. Normalization in relational databases is only feasible under the premise that JOINs between tables are relatively cheap. The $lookup aggregation operator provides some limited JOIN functionality, but it doesn't work with sharded collections. So joins often need to be emulated by the application through multiple subsequent database queries, which is very slow (see question MongoDB and JOINs for more information).

Source: stackoverflow.com

Q18: How does MongoDB provide concurrency? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: What are Primary and Secondary Replica sets? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: How does Journaling work in MongoDB? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: When to Redis or MongoDB? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: MongoDB relationships. What to use - embed or reference? ⭐⭐⭐⭐

Details: I want to design a question structure with some comments, but I don't know which relationship to use for comments: embed or reference? Explain me pros and cons of both solutions?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: Is MongoDB schema-less? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: How does MongoDB ensure high availability? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: How to check if a field contains a substring? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: What are alternatives to MongoDB? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: How to find document with array that contains a specific value? ⭐⭐⭐⭐⭐

Details: You have this schema:

person = {
    name : String,
    favoriteFoods : Array
}

where the favoriteFoods array is populated with strings. How can I find all persons that have sushi as their favorite food using MongoDB?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: Is it possible to update MongoDB field using value of another field? ⭐⭐⭐⭐⭐

Details: In SQL we will use:

UPDATE Person SET Name = FirstName + ' ' + LastName

Is it possible with MongoDB?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: Explain what is horizontal scalability? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: What are the differences between MongoDB and MySQL? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 30 Docker Interview Questions and Answers in 2019 | FullStack.Cafe

Q1: What is the need for DevOps? ⭐

Answer: Nowadays instead of releasing big sets of features, companies are trying to see if small features can be transported to their customers through a series of release trains. This has many advantages like quick feedback from customers, better quality of software etc. which in turn leads to high customer satisfaction. To achieve this, companies are required to:

  1. Increase deployment frequency
  2. Lower failure rate of new releases
  3. Shortened lead time between fixes
  4. Faster mean time to recovery in the event of new release crashing

DevOps fulfills all these requirements and helps in achieving seamless software delivery. 

Source: edureka.co

Q2: What are the advantages of DevOps? ⭐⭐

Answer: Technical benefits:

  • Continuous software delivery
  • Less complex problems to fix
  • Faster resolution of problems

Business benefits:

  • Faster delivery of features
  • More stable operating environments
  • More time available to add value (rather than fix/maintain)

Source: edureka.co

Q3: What is the function of CI (Continuous Integration) server? ⭐⭐

Answer: CI server function is to continuously integrate all changes being made and committed to repository by different developers and check for compile errors. It needs to build code several times a day, preferably after every commit so it can detect which commit made the breakage if the breakage happens.

Source: linoxide.com

Q4: What is Docker? ⭐

Answer:

  • Docker is a containerization platform which packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment be it development or test or production.
  • Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries etc. anything that can be installed on a server.
  • This guarantees that the software will always run the same, regardless of its environment.

Source: edureka.co

Q5: How to build envrionment-agnostic systems with Docker? ⭐⭐

Answer: There are three main features helping to achieve that:

  • Volumes
  • Environment variable injection
  • Read-only file systems

Source: rafalgolarz.com

Q6: What is the difference between the COPY and ADD commands in a Dockerfile? ⭐⭐

Answer: Although ADD and COPY are functionally similar, generally speaking, COPY is preferred.

That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.

Source: stackoverflow.com

Q7: What is Docker image? ⭐⭐

Answer: Docker image is the source of Docker container. In other words, Docker images are used to create containers. Images are created with the build command, and they’ll produce a container when started with run. Images are stored in a Docker registry such as registry.hub.docker.com because they can become quite large, images are designed to be composed of layers of other images, allowing a minimal amount of data to be sent when transferring images over the network.

Source: edureka.co

Q8: What is Docker container? ⭐⭐

Answer: Docker containers include the application and all of its dependencies, but share the kernel with other containers, running as isolated processes in user space on the host operating system. Docker containers are not tied to any specific infrastructure: they run on any computer, on any infrastructure, and in any cloud.

Source: edureka.co

Q9: What is Docker hub? ⭐⭐

Answer: Docker hub is a cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images, and links to Docker cloud so you can deploy images to your hosts. It provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, and workflow automation throughout the development pipeline.

Source: edureka.co

Q10: What are the various states that a Docker container can be in at any given point in time? ⭐⭐

Answer: There are four states that a Docker container can be in, at any given point in time. Those states are as given as follows:

  • Running
  • Paused
  • Restarting
  • Exited

Source: mindmajix.com

Q11: Is there a way to identify the status of a Docker container? ⭐⭐

Answer: We can identify the status of a Docker container by running the command

docker ps –a

which will in turn list down all the available docker containers with its corresponding statuses on the host. From there we can easily identify the container of interest to check its status correspondingly.

Source: mindmajix.com

Q12: What are the most common instructions in Dockerfile? ⭐⭐

Answer:

Some of the common instructions in Dockerfile are as follows:

  • FROM: We use FROM to set the base image for subsequent instructions. In every valid Dockerfile, FROM is the first instruction.
  • LABEL: We use LABEL to organize our images as per project, module, licensing etc. We can also use LABEL to help in automation.
    In LABEL we specify a key value pair that can be later used for programmatically handling the Dockerfile.
  • RUN: We use RUN command to execute any instructions in a new layer on top of the current image. With each RUN command we add something on top of the image and use it in subsequent steps in Dockerfile.
  • CMD: We use CMD command to provide default values of an executing container. In a Dockerfile, if we include multiple CMD commands, then only the last instruction is used.

Source: knowledgepowerhouse.com

Q13: What type of applications - Stateless or Stateful are more suitable for Docker Container? ⭐⭐

Answer: It is preferable to create Stateless application for Docker Container. We can create a container out of our application and take out the configurable state parameters from application. Now we can run same container in Production as well as QA environments with different parameters. This helps in reusing the same Image in different scenarios. Also a stateless application is much easier to scale with Docker Containers than a stateful application.

Source: mindmajix.com

Q14: Explain basic Docker usage workflow ⭐⭐⭐

Answer:

  1. Everything starts with the Dockerfile. The Dockerfile is the source code of the Image.
  2. Once the Dockerfile is created, you build it to create the image of the container. The image is just the "compiled version" of the "source code" which is the Dockerfile.
  3. Once you have the image of the container, you should redistribute it using the registry. The registry is like a git repository -- you can push and pull images.
  4. Next, you can use the image to run containers. A running container is very similar, in many aspects, to a virtual machine (but without the hypervisor).
    +------------+  docker build   +--------------+  docker run -dt   +-----------+  docker exec -it   +------+
    | Dockerfile | --------------> |    Image     | --------------->  | Container | -----------------> | Bash |
    +------------+                 +--------------+                   +-----------+                    +------+
                                     ^
                                     | docker pull
                                     |
                                   +--------------+
                                   |   Registry   |
                                   +--------------+

Source: stackoverflow.com

Q15: What is the difference between Docker Image and Layer? ⭐⭐⭐

Answer:

  • Image: A Docker image is built up from a series of read-only layers
  • Layer: Each layer represents an instruction in the image’s Dockerfile.

The below Dockerfile contains four commands, each of which creates a layer.

FROM ubuntu:15.04
COPY . /app
RUN make /app
CMD python /app/app.py

Importantly, each layer is only a set of differences from the layer before it.

Source: stackoverflow.com

Q16: What is virtualisation? ⭐⭐⭐

Answer: In its conceived form, virtualisation was considered a method of logically dividing mainframes to allow multiple applications to run simultaneously. However, the scenario drastically changed when companies and open source communities were able to provide a method of handling the privileged instructions in one way or another and allow for multiple operating systems to be run simultaneously on a single x86 based system.

The net effect is that virtualization allows you to run two completely different OS on same hardware. Each guest OS goes through all the process of bootstrapping, loading kernel etc. You can have very tight security, for example, guest OS can't get full access to host OS or other guests and mess things up.

The virtualization method can be categorized based on how it mimics hardware to a guest operating system and emulates guest operating environment. Primarily, there are three types of virtualization:

  • Emulation
  • Paravirtualization
  • Container-based virtualization

Source: stackoverflow.com

Q17: What is Hypervisor? ⭐⭐⭐

Answer: The hypervisor handles creating the virtual environment on which the guest virtual machines operate. It supervises the guest systems and makes sure that resources are allocated to the guests as necessary. The hypervisor sits in between the physical machine and virtual machines and provides virtualization services to the virtual machines. To realize it, it intercepts the guest operating system operations on the virtual machines and emulates the operation on the host machine's operating system.

The rapid development of virtualization technologies, primarily in cloud, has driven the use of virtualization further by allowing multiple virtual servers to be created on a single physical server with the help of hypervisors, such as Xen, VMware Player, KVM, etc., and incorporation of hardware support in commodity processors, such as Intel VT and AMD-V.

Source: stackoverflow.com

Q18: What is Docker Swarm? ⭐⭐⭐

Answer: Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host. Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.

Source: edureka.co

Q19: How will you monitor Docker in production? ⭐⭐⭐

Answer: Docker provides tools like docker stats and docker events to monitor Docker in production. We can get reports on important statistics with these commands.

  • Docker stats: When we call docker stats with a container id, we get the CPU, memory usage etc of a container. It is similar to top command in Linux.
  • Docker events: Docker events are a command to see the stream of activities that are going on in Docker daemon.

Some of the common Docker events are: attach, commit, die, detach, rename, destroy etc. We can also use various options to limit or filter the events that we are interested in.

Source: knowledgepowerhouse.com

Q20: What is an orphant volume and how to remove it? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: What is Paravirtualization? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: How is Docker different from a virtual machine? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: Can you explain dockerfile ONBUILD instruction? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: Is it good practice to run stateful applications on Docker? What are the scenarios where Docker best fits in? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Can you run Docker containers natively on Windows? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: How does Docker run containers in non-Linux systems? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: How containers works at low level? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: Name some limitations of containers vs VM ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: How to use Docker with multiple environments? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Why Docker compose does not wait for a container to be ready before moving on to start next service in dependency order? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

[⬆] <a name=32jQueryInterviewQuestionsYou'llSimplyFailOn>32 jQuery Interview Questions You'll Simply Fail On

Originally published on 👉 32 jQuery Interview Questions You'll Simply Fail On | FullStack.Cafe

Q1: What is jQuery? ⭐

Answer: jQuery is fast, lightweight and feature-rich client side JavaScript Library/Framework which helps in to traverse HTML DOM, make animations, add Ajax interaction, manipulate the page content, change the style and provide cool UI effect. It is one of the most popular client side library and as per a survey it runs on every second website.

Source: codeproject.com

Q2: Why do we use jQuery? ⭐⭐

Answer: Due to following advantages.

  • Easy to use and learn.
  • Easily expandable.
  • Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
  • Easy to use for DOM manipulation and traversal.
  • Large pool of built in methods.
  • AJAX Capabilities.
  • Methods for changing or applying CSS, creating animations.
  • Event detection and handling.
  • Tons of plug-ins for all kind of needs.

Source: codeproject.com

Q3: How JavaScript and jQuery are different? ⭐⭐

Answer: JavaScript is a language While jQuery is a library built in the JavaScript language that helps to use the JavaScript language.

Source: codeproject.com

Q4: Is jQuery a W3C standard? ⭐⭐

Answer: No. jQuery is not a W3C standard.

Source: codeproject.com

Q5: What does dollar sign ($) means in jQuery? ⭐⭐

Answer: Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code.

$(document).ready(function(){
});

Over here $ sign can be replaced with "jQuery" keyword.

jQuery(document).ready(function(){
});

Source: codeproject.com

Q6: Can we have multiple document.ready() function on the same page? ⭐⭐

Answer: YES. We can have any number of document.ready() function on the same page.

Source: codeproject.com

Q7: What is jQuery.noConflict? ⭐⭐

Answer: As other client side libraries like MooTools, Prototype can be used with jQuery and they also use $() as their global function and to define variables. This situation creates conflict as $() is used by jQuery and other library as their global function. To overcome from such situations, jQuery has introduced jQuery.noConflict().

jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
   jQuery("div").hide();
});  

You can also use your own specific character in the place of $ sign in jQuery.

var $j = jQuery.noConflict();
// Use jQuery via jQuery(...)
$j(document).ready(function(){
   $j("div").hide();
});  

Source: codeproject.com

Q8: What is the difference between .js and .min.js? ⭐⭐

Answer: jQuery library comes in 2 different versions Development and Production/Deployment. The deployment version is also known as minified version. So .min.js is basically the minified version of jQuery library file. Both the files are same as far as functionality is concerned. but .min.js is quite small in size so it loads quickly and saves bandwidth.

Source: codeproject.com

Q9: How do you select element by ID in jQuery? ⭐⭐

Answer: To select element use ID selector. We need to prefix the id with "#" (hash symbol). For example, to select element with ID "txtName", then syntax would be,

$('#txtName')

Source: codeproject.com

Q10: What does $("div.parent") will select? ⭐⭐

Answer: All the div element with parent class.

Source: codeproject.com

Q11: What is the use of jquery .each() function? ⭐⭐

Answer: The $.each() function is used to iterate over a jQuery object. The $.each() function can be used to iterate over any collection, whether it is an object or an array.

Source: codeproject.com

Q12: Is there any difference between body onload() and document.ready() function? ⭐⭐⭐

Answer: document.ready() function is different from body onload() function for several reasons:

  1. We can have more than one document.ready() function in a page where we can have only one body onload function.
  2. document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.

Source: codeproject.com

Q13: What are the fastest/slowest selectors in jQuery? ⭐⭐⭐

Answer: ID and element selectors are the fastest selectors in jQuery. Class selectors are the slow compared to ID and element.

Source: codeproject.com

Q14: Which is fast document.getElementByID('txtName') or $('#txtName').? ⭐⭐⭐

Answer: Native JavaScipt is always fast. jQuery method to select txtName "$('#txtName')" will internally makes a call to document.getElementByID('txtName'). As jQuery is written on top of JavaScript and it internally uses JavaScript only so JavaScript is always fast.

Source: codeproject.com

Q15: Difference between $(this) and 'this' in jQuery? ⭐⭐⭐

Answer: this and $(this) refers to the same element. The only difference is the way they are used. 'this' is used in traditional sense, when 'this' is wrapped in $() then it becomes a jQuery object and you are able to use the power of jQuery.

$(document).ready(function(){
    $('#spnValue').mouseover(function(){
       alert($(this).text());
  });
});

In below example, this is an object but since it is not wrapped in $(), we can't use jQuery method and use the native JavaScript to get the value of span element.

$(document).ready(function(){
    $('#spnValue').mouseover(function(){
       alert(this.innerText);
  });
});

Source: codeproject.com

Q16: What is the difference between eq() and get() methods in jQuery? ⭐⭐⭐

Answer:

  • eq() returns the element as a jQuery object. This method constructs a new jQuery object from one element within that set and returns it. That means that you can use jQuery functions on it.
  • get() return a DOM element. The method retrieve the DOM elements matched by the jQuery object. But as it is a DOM element and it is not a jQuery-wrapped object. So jQuery functions can't be used.

Source: codeproject.com

Q17: What is wrong with this code line "$('#myid\.3').text('blah blah!!!');" ⭐⭐⭐

Answer: The problem with above statement is that the selectors is having meta characters and to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar").
So the correct syntax is:

$('#myid\\\\.3').text('blah blah!!!');

Source: codeproject.com

Q18: How to create clone of any object using jQuery? ⭐⭐⭐

Answer: jQuery provides clone() method which performs a deep copy of the set of matched elements, meaning that it copies the matched elements as well as all of their descendant elements and text nodes.

$(document).ready(function(){
  $('#btnClone').click(function(){
     $('#dvText').clone().appendTo('body');
     return false;
  });
});

The default implementation of the clone() method doesn't copy events unless you tell the clone() method to copy the events. The clone() method takes a parameter, if you pass true then it will copy the events as well.

$(document).ready(function(){
   $("#btnClone").bind('click', function(){
     $('#dvClickme').clone(true).appendTo('body');
  });

Source: codeproject.com

Q19: What is difference between prop and attr? ⭐⭐⭐

Answer: attr(): Get the value of an attribute for the first element in the set of matched elements. Whereas, .prop(): (Introduced in jQuery 1.6) Get the value of a property for the first element in the set of matched elements.

Attributes carry additional information about an HTML element and come in name="value" pairs. Where Property is a representation of an attribute in the HTML DOM tree. once the browser parse your HTML code ,corresponding DOM node will be created which is an object thus having properties.

attr() gives you the value of element as it was defines in the html on page load. It is always recommended to use prop() to get values of elements which is modified via javascript/jquery , as it gives you the original value of an element's current state. Find out more here.

Source: codeproject.com

Q20: What are various methods to make ajax request in jQuery? ⭐⭐⭐

Answer: Using below jQuery methods, you can make ajax calls.

  • load() : Load a piece of html into a container DOM
  • $.getJSON(): Load JSON with GET method.
  • $.getScript(): Load a JavaScript file.
  • $.get(): Use to make a GET call and play extensively with the response.
  • $.post(): Use to make a POST call and don't want to load the response to some container DOM.
  • $.ajax(): Use this to do something on XHR failures, or to specify ajax options (e.g. cache: true) on the fly.

Source: codeproject.com

Q21: What is the difference between $('div') and $('
') in jQuery? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: What is the difference between event.PreventDefault and "return false"? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: How do you attach a event to element which should be executed only once? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: In what situation you would use multiple version of jQuery and how would you include them? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: What are deferred and promise object in jQuery? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: What are the differences between JavaScript's window.onload and jQuery's $(document).ready() method? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: Is there any significant difference between event.preventDefault() vs. return false to stop event propagation? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Is it possible to hold or delay document.ready execution for sometime? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: Is it possible to get value of multiple CSS properties in single statement? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: How can I implement my own $(document).ready functionality without using jQuery? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 33 Frequently Asked Node.js Interview Questions (2020 Update) | FullStack.Cafe

Q1: What is Node.js? ⭐

Answer: Node.js is a web application framework built on Google Chrome's JavaScript Engine (V8 Engine).

Node.js comes with runtime environment on which a Javascript based script can be interpreted and executed (It is analogus to JVM to JAVA byte code). This runtime allows to execute a JavaScript code on any machine outside a browser. Because of this runtime of Node.js, JavaScript is now can be executed on server as well.

Node.js = Runtime Environment + JavaScript Library

Source: tutorialspoint.com

Q2: What do you mean by Asynchronous API? ⭐⭐

Answer: All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.

Source: tutorialspoint.com

Q3: What are the benefits of using Node.js? ⭐⭐

Answer: Following are main benefits of using Node.js

  • Aynchronous and Event Driven - All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
  • Very Fast - Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.
  • Single Threaded but highly Scalable - Node.js uses a single threaded model with event looping. Event mechanism helps server to respond in a non-bloking ways and makes server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and same program can services much larger number of requests than traditional server like Apache HTTP Server.
  • No Buffering - Node.js applications never buffer any data. These applications simply output the data in chunks.

Source: tutorialspoint.com

Q4: What are the key features of Node.js? ⭐⭐

Answer: Let’s look at some of the key features of Node.js.

  • Asynchronous event driven IO helps concurrent request handling – All APIs of Node.js are asynchronous. This feature means that if a Node receives a request for some Input/Output operation, it will execute that operation in the background and continue with the processing of other requests. Thus it will not wait for the response from the previous requests.
  • Fast in Code execution – Node.js uses the V8 JavaScript Runtime engine, the one which is used by Google Chrome. Node has a wrapper over the JavaScript engine which makes the runtime engine much faster and hence processing of requests within Node.js also become faster.
  • Single Threaded but Highly Scalable – Node.js uses a single thread model for event looping. The response from these events may or may not reach the server immediately. However, this does not block other operations. Thus making Node.js highly scalable. Traditional servers create limited threads to handle requests while Node.js creates a single thread that provides service to much larger numbers of such requests.
  • Node.js library uses JavaScript – This is another important aspect of Node.js from the developer’s point of view. The majority of developers are already well-versed in JavaScript. Hence, development in Node.js becomes easier for a developer who knows JavaScript.
  • There is an Active and vibrant community for the Node.js framework – The active community always keeps the framework updated with the latest trends in the web development.
  • No Buffering – Node.js applications never buffer any data. They simply output the data in chunks.

Source: techbeamers.com

Q5: What is libuv? ⭐⭐

Answer: libuv is a C library that is used to abstract non-blocking I/O operations to a consistent interface across all supported platforms. It provides mechanisms to handle file system, DNS, network, child processes, pipes, signal handling, polling and streaming. It also includes a thread pool for offloading work for some things that can't be done asynchronously at the operating system level.

Source: nodejs.org

Q6: What is a blocking code? ⭐⭐⭐

Answer: If application has to wait for some I/O operation in order to complete its execution any further then the code responsible for waiting is known as blocking code.

Source: tutorialspoint.com

Q7: What is difference between synchronous and asynchronous method of fs module? ⭐⭐⭐

Answer:

Every method in fs module has synchronous as well as asynchronous form. Asynchronous methods takes a last parameter as completion function callback and first parameter of the callback function is error. It is preferred to use asynchronous method instead of synchronous method as former never block the program execution where the latter one does.

Source: tutorialspoint.com

Q8: What is Chaining in Node? ⭐⭐⭐

Answer: Chanining is a mechanism to connect output of one stream to another stream and create a chain of multiple stream operations. It is normally used with piping operations.

Source: tutorialspoint.com

Q9: What's the event loop? ⭐⭐⭐

Answer: The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.

Every I/O requires a callback - once they are done they are pushed onto the event loop for execution. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback may be added to the poll queue to eventually be executed.

Source: blog.risingstack.com

Q10: When should we use Node.js? ⭐⭐⭐

Answer: Node.js is well suited for applications that have a lot of concurrent connections and each request only needs very few CPU cycles, because the event loop (with all the other clients) is blocked during execution of a function. I believe Node.js is best suited for real-time applications: online games, collaboration tools, chat rooms, or anything where what one user (or robot? or sensor?) does with the application needs to be seen by other users immediately, without a page refresh.

Source: techbeamers.com

Q11: How does Node.js handle child threads? ⭐⭐⭐

Answer: Node.js, in its essence, is a single thread process. It does not expose child threads and thread management methods to the developer. Technically, Node.js does spawn child threads for certain tasks such as asynchronous I/O, but these run behind the scenes and do not execute any application JavaScript code, nor block the main event loop.

If threading support is desired in a Node.js application, there are tools available to enable it, such as the ChildProcess module.

Source: lazyquestion.com

Q12: What is the preferred method of resolving unhandled exceptions in Node.js? ⭐⭐⭐

Answer: Unhandled exceptions in Node.js can be caught at the Process level by attaching a handler for uncaughtException event.

process.on('uncaughtException', function(err) {
  console.log('Caught exception: ' + err);
});

However, uncaughtException is a very crude mechanism for exception handling and may be removed from Node.js in the future. An exception that has bubbled all the way up to the Process level means that your application, and Node.js may be in an undefined state, and the only sensible approach would be to restart everything.

The preferred way is to add another layer between your application and the Node.js process which is called the domain.

Domains provide a way to handle multiple different I/O operations as a single group. So, by having your application, or part of it, running in a separate domain, you can safely handle exceptions at the domain level, before they reach the Process level.

Source: lazyquestion.com

Q13: How to use Buffer in Node.js? ⭐⭐⭐

Answer: Buffer is used to process binary data, such as pictures, mp3, database files, etc. Buffer supports a variety of encoding and decoding, binary string conversion.

Source: github.com/jimuyouyou

Q14: Rewrite promise-based Node.js applications to Async/Await ⭐⭐⭐

Details: Rewrite this code to Async/Await:

function asyncTask() {
    return functionA()
        .then((valueA) => functionB(valueA))
        .then((valueB) => functionC(valueB))
        .then((valueC) => functionD(valueC))
        .catch((err) => logger.error(err))
}

Answer:

async function asyncTask() {
    try {
        const valueA = await functionA()
        const valueB = await functionB(valueA)
        const valueC = await functionC(valueB)
        return await functionD(valueC)
    } catch (err) {
        logger.error(err)
    }
}

Source: stackoverflow.com

Q15: Are you familiar with differences between Node.js nodules and ES6 nodules? ⭐⭐⭐

Answer: The modules used in Node.js follow a module specification known as the CommonJS specification. The recent updates to the JavaScript programming language, in the form of ES6, specify changes to the language, adding things like new class syntax and a module system. This module system is different from Node.js modules. To import ES6 module, we'd use the ES6 import functionality.

Now ES6 modules are incompatible with Node.js modules. This has to do with the way modules are loaded differently between the two formats. If you use a compiler like Babel, you can mix and match module formats.

Source: stackoverflow.com

Q16: Name some of the events fired by streams. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: What's a stub? Name a use case. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Is Node.js entirely based on a single-thread? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: When to not use Node.js? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: What are the timing features of Node.js? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: How would you handle errors for async code in Node.js? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: How do you convert an existing callback API to promises? ⭐⭐⭐⭐

Details: How to convert this callback code to Promise? Provide some examples.

function divisionAPI (number, divider, successCallback, errorCallback) {
    if (divider == 0) {
        return errorCallback( new Error("Division by zero") )
    }
    successCallback( number / divider )
}

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: Can Node.js work without V8? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: Is it possible to use "Class" in Node.js? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Can Node.js use other engines than V8? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: What is the difference between process.nextTick() and setImmediate() ? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: Explain what is Reactor Pattern in Node.js? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: Why should you separate Express 'app' and 'server'? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: How many threads does Node actually create? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: How V8 compiles JavaScript code? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: What is V8 Templates? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: Why Node.js devs tend to lean towards the Module Requiring vs Dependency Injection? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: What will happen when that code will be executed? ⭐⭐⭐⭐⭐

Details:

What will happen when that code will be executed?

var EventEmitter = require('events');

var crazy = new EventEmitter();

crazy.on('event1', function () {
    console.log('event1 fired!');
    process.nextTick(function () {
        crazy.emit('event2');
    });
});

crazy.on('event2', function () {
    console.log('event2 fired!');
    process.nextTick(function () {
        crazy.emit('event3');
    });

});

crazy.on('event3', function () {
    console.log('event3 fired!');
    process.nextTick(function () {
        crazy.emit('event1');
    });
});

crazy.emit('event1');

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 35 LINQ Interview Questions and Answers in 2019 | FullStack.Cafe

Q1: What is LINQ? ⭐

Answer: LINQ stands for Language INtegrated Query. LINQ allows us to write queries over local collection objects and remote data sources like SQL, XML documents etc. We can write LINQ query on any collection class which implements the IEnumerable interface.

Source: stackoverflow.com

Q2: What are the types of LINQ? ⭐

Answer:

  • LINQ to Objects
  • LINQ to XML
  • LINQ to Dataset
  • LINQ to SQL
  • LINQ to Entities

Source: career.guru99.com

Q3: Explain what is LINQ? Why is it required? ⭐

Answer: Language Integrated Query or LINQ is the collection of standard query operators which provides query facilities into.NET framework language like C#, VB.NET. LINQ is required as it bridges the gap between the world of data and the world of objects.

Source: career.guru99.com

Q4: List out the three main components of LINQ? ⭐⭐

Answer: Three main components of LINQ are

  • Standard Query Operators
  • Language Extensions
  • LINQ Providers

Source: career.guru99.com

Q5: What is Anonymous function? ⭐⭐

Answer: An Anonymous function is a special function which does not have any name. We just define their parameters and define the code into the curly braces.

Consider:

delegate int func(int a, int b);
static void Main(string[] args)
{
    func f1 = delegate(int a, int b)
    {
        return a + b;
    };
 
    Console.WriteLine(f1(1, 2));
}

Source: stackoverflow.com

Q6: What are Anonymous Types? ⭐⭐

Answer: Anonymous types are types that are generated by compiler at run time. When we create a anonymous type we do not specify a name. We just write properties names and their values. Compiler at runtime create these properties and assign values to them.

var k = new { FirstProperty = "value1", SecondProperty = "value2" };
Console.WriteLine(k.FirstProperty);

Anonymous class is useful in LINQ queries to save our intermediate results.

There are some restrictions on Anonymous types as well:

  • Anonymous types can not implement interfaces.
  • Anonymous types can not specify any methods.
  • We can not define static members.
  • All defined properties must be initialized.
  • We can only define public fields.

Source: stackoverflow.com

Q7: What are Extension Methods? ⭐⭐

Answer: Extension methods are static functions of a static class. These methods can be invoked just like instance method syntax. These methods are useful when we can not want to modify the class. Consider:

public static class StringMethods
{
    public static bool IsStartWithLetterM(this string s)
    {
        return s.StartsWith("m");
    }
}
class Program
{
    static void Main(string[] args)
    {
        string value = "malslfds";
        Console.WriteLine(value.IsStartWithLetterM()); //print true;
 
        Console.ReadLine();
    }
}

Source: stackoverflow.com

Q8: Explain what is “LINQ to Objects”? ⭐⭐

Answer: When LINQ queries any IEnumerable(<T>) collection or IEnumerable directly without the use of an intermediate LINQ provider or API such as LINQ to SQL or LINQ to XML is referred as LINQ to Objects.

Source: career.guru99.com

Q9: Explain what is the purpose of LINQ providers in LINQ? ⭐⭐

Answer: LINQ providers are set of classes that take an LINQ query which generates method that executes an equivalent query against a particular data source.

Source: career.guru99.com

Q10: Mention what is the role of DataContext classes in LINQ? ⭐⭐

Answer: DataContext class acts as a bridge between SQL Server database and the LINQ to SQL. For accessing the database and also for changing the data in the database, it contains connections string and the functions. Essentially a DataContext class performs the following three tasks:

  • Create connection to database.
  • It submits and retrieves object to database.
  • Converts objects to SQL queries and vice versa.

Source: career.guru99.com

Q11: In LINQ how will you find the index of the element using where() with Lambda Expressions? ⭐⭐

Answer: In order to find the index of the element use the overloaded version of where() with the lambda expression:

where(( i, ix ) => i == ix);

Source: career.guru99.com

Q12: Explain how LINQ is useful than Stored Procedures? ⭐⭐

Answer:

  • Debugging: It is difficult to debug a stored procedure but as LINQ is part of.NET, visual studio debugger can be used to debug the queries
  • Deployment: For stored procedure, additional script should be provided but with LINQ everything gets compiled into single DLL hence deployment becomes easy
  • Type Safety: LINQ is type safe, so queries errors are type checked at compile time

Source: career.guru99.com

Q13: Explain why SELECT clause comes after FROM clause in LINQ? ⭐⭐

Answer: With other programming language and C#, LINQ is used, it requires all the variables to be declared first. “FROM” clause of LINQ query defines the range or conditions to select records. So, FROM clause must appear before SELECT in LINQ.

Source: career.guru99.com

Q14: Could you compare Entity Framework vs LINQ to SQL vs ADO.NET with stored procedures? ⭐⭐⭐

Answer: Stored procedures:

(++)

  • Great flexibility
  • Full control over SQL
  • The highest performance available

(--)

  • Requires knowledge of SQL
  • Stored procedures are out of source control (harder to test)
  • Substantial amount of "repeating yourself" while specifying the same table and field names. The high chance of breaking the application after renaming a DB entity and missing some references to it somewhere.
  • Slow development

ORM (EF, L2SQL, ADO.NET):

(++)

  • Rapid development
  • Data access code now under source control
  • You're isolated from changes in DB. If that happens you only need to update your model/mappings in one place.

(--)

  • Performance may be worse
  • No or little control over SQL the ORM produces (could be inefficient or worse buggy). Might need to intervene and replace it with custom stored procedures. That will render your code messy (some LINQ in code, some SQL in code and/or in the DB out of source control).
  • As any abstraction can produce "high-level" developers having no idea how it works under the hood

Source: stackoverflow.com

Q15: When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference? ⭐⭐⭐

Answer:

  • LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5.

  • LINQ to Entities (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the .Net Framework 3.5 SP1.

Source: stackoverflow.com

Q16: Using LINQ to remove elements from a List ⭐⭐⭐

Details: Given that authorsList is of type List<Author>, how can I delete the Author elements that are equalling to Bob?

Answer: Consider:

authorsList.RemoveAll(x => x.FirstName == "Bob");

Source: stackoverflow.com

Q17: What is the difference between First() and Take(1)? ⭐⭐⭐

Details: Consider:

var result = List.Where(x => x == "foo").First();
var result = List.Where(x => x == "foo").Take(1);

Answer: The difference between First() and Take() is that First() returns the element itself, while Take() returns a sequence of elements that contains exactly one element. (If you pass 1 as the parameter).

Source: stackoverflow.com

Q18: When to use First() and when to use FirstOrDefault() with LINQ? ⭐⭐⭐

Answer:

  • Use First() when you know or expect the sequence to have at least one element. In other words, when it is an exceptional occurrence that the sequence is empty.
  • Use FirstOrDefault() when you know that you will need to check whether there was an element or not. In other words, when it is legal for the sequence to be empty. You should not rely on exception handling for the check. (It is bad practice and might hurt performance).

First() will throw an exception if there's no row to be returned, while FirstOrDefault() will return the default value (NULL for all reference types) instead.

Source: stackoverflow.com

Q19: Explain how standard query operators useful in LINQ? ⭐⭐⭐

Answer: A set of extension methods forming a query pattern is known as LINQ Standard Query Operators. As building blocks of LINQ query expressions, these operators offer a range of query capabilities like filtering, sorting, projection, aggregation, etc.

LINQ standard query operators can be categorized into the following ones on the basis of their functionality.

  • Filtering Operators (Where, OfType)
  • Join Operators (Join, GroupJoin)
  • Projection Operations (Select, SelectMany)
  • Sorting Operators (OrderBy, ThenBy, Reverse, ...)
  • Grouping Operators (GroupBy, ToLookup)
  • Conversions (Cast, ToArray, ToList, ...)
  • Concatenation (Concat)
  • Aggregation (Aggregate, Average, Count, Max, ...)
  • Quantifier Operations (All, Any, Contains)
  • Partition Operations (Skip, SkipWhile, Take, ...)
  • Generation Operations (DefaultIfEmpty, Empty, Range, Repeat)
  • Set Operations (Distinct, Except, ...)
  • Equality (SequenceEqual)
  • Element Operators (ElementAt, First, Last, ...)

Source: tutorialspoint.com

Q20: What is Expression Trees and how they used in LINQ? ⭐⭐⭐

Answer: An Expression Tree is a data structure that contains Expressions, which is basically code. So it is a tree structure that represents a calculation you may make in code. These pieces of code can then be executed by "running" the expression tree over a set of data.

In LINQ, expression trees are used to represent structured queries that target sources of data that implement IQueryable<T>. For example, the LINQ provider implements the IQueryable<T> interface for querying relational data stores. The C# compiler compiles queries that target such data sources into code that builds an expression tree at runtime. The query provider can then traverse the expression tree data structure and translate it into a query language appropriate for the data source.

Source: docs.microsoft.com

Q21: Could you explian what is the exact deference between deferred execution and Lazy evaluation in C#? ⭐⭐⭐

Answer: In practice, they mean essentially the same thing. However, it's preferable to use the term deferred.

  • Lazy means "don't do the work until you absolutely have to."
  • Deferred means "don't compute the result until the caller actually uses it."

When the caller decides to use the result of an evaluation (i.e. start iterating through an IEnumerable<T>), that is precisely the point at which the "work" needs to be done (such as issuing a query to the database).

The term deferred is more specific/descriptive as to what's actually going on. When I say that I am lazy, it means that I avoid doing unnecessary work; it's ambiguous as to what that really implies. However, when I say that execution/evaluation is deferred, it essentially means that I am not giving you the real result at all, but rather a ticket you can use to claim the result. I defer actually going out and getting that result until you claim it.

Source: stackoverflow.com

Q22: Explain what are LINQ compiled queries? ⭐⭐⭐

Answer: There may be scenario where we need to execute a particular query many times and repeatedly. LINQ allows us to make this task very easy by enabling us to create a query and make it compiled always. Benefits of Compiled Queries:

  • Query does need to compiled each time so execution of the query is fast.
  • Query is compiled once and can be used any number of times.
  • Query does need to be recompiled even if the parameter of the query is being changed.

Consider:

static class MyCompliedQueries {
	public static Func <DataClasses1DataContext, IQueryable <Person>> CompliedQueryForPerson = 
        CompiledQuery.Compile((DataClasses1DataContext context) = >from c in context.Persons select c);
}

Source: career.guru99.com

Q23: Get the indexes of top n items where item value = true ⭐⭐⭐

Details: I have a List<bool>. I need to get the indexes of top n items where item value = true.

10011001000

TopTrueIndexes(3) = The first 3 indexes where bits are true are 0, 3, 4 
TopTrueIndexes(4) = The first 4 indexes where bits are true are 0, 3, 4, 7 

Answer: Assuming you have some easily-identifiable condition, you can do something like this, which will work for any IEnumerable<T>:

var query = source.Select((value, index) => new { value, index })
                  .Where(x => x.value => Condition(value))
                  .Select(x => x.index)
                  .Take(n);

The important bits are that you use the overload of Select to get index/value pairs before the Where, and then another Select to get just the indexes after the Where... and use Take to only get the first n results.

Source: stackoverflow.com

Q24: Define what is Let clause? ⭐⭐⭐

Answer: In a query expression, it is sometimes useful to store the result of a sub-expression in order to use it in subsequent clauses. You can do this with the let keyword, which creates a new range variable and initializes it with the result of the expression you supply.

Consider:

var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" };
var result =
    from animalName in names
    let nameLength = animalName.Length
    where nameLength > 3
    orderby nameLength
    select animalName; 

Source: career.guru99.com

Q25: Explain what is the difference between Skip() and SkipWhile() extension method? ⭐⭐⭐

Answer:

  • Skip() : It will take an integer argument and from the given IEnumerable it skips the top n numbers
  • SkipWhile (): It will continue to skip the elements as far as the input condition is true. It will return all remaining elements if the condition is false.

Source: career.guru99.com

Q26: Explain what is lambda expressions in LINQ? ⭐⭐⭐

Answer: Lambda expression is referred as a unique function use to form delegates or expression tree types, where right side is the output and left side is the input to the method. For writing LINQ queries particularly, Lambda expression is used.

Source: career.guru99.com

Q27: Name some advantages of LINQ over Stored Procedures ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: What are the benefits of a Deferred Execution in LINQ? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: When should I use a CompiledQuery? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: What is an equivalent to the "let" keyword in chained LINQ extension method calls? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: Can you provide a concise distinction between anonymous method and lambda expressions? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: Name some disadvantages of LINQ over sprocs ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: What is the difference between Select and SelectMany? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q34: What is the difference between returning IQueryable vs. IEnumerable? ⭐⭐⭐⭐⭐

Details: What is the difference between returning IQueryable<T> vs. IEnumerable<T>?

IQueryable < Customer > custs = from c in db.Customers
where c.City == "<City>"
select c;

IEnumerable < Customer > custs = from c in db.Customers
where c.City == "<City>"
select c;

Will both be deferred execution and when should one be preferred over the other?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q35: Why use .AsEnumerable() rather than casting to IEnumerable? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

[⬆] <a name=35MicroservicesInterviewQuestionsYouMostLikelyCan'tAnswer>35 Microservices Interview Questions You Most Likely Can't Answer

Originally published on 👉 35 Microservices Interview Questions You Most Likely Can't Answer | FullStack.Cafe

Q1: What is meant by Continuous Integration? ⭐

Answer: Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

Source: edureka.co

Q2: What does Containerization mean? ⭐⭐

Answer: Containerisation is a type of virtualization strategy that emerged as an alternative to traditional hypervisor-based virtualization.

In containerization, the operating system is shared by the different containers rather than cloned for each virtual machine. For example Docker provides a container virtualization platform that serves as a good alternative to hypervisor-based arrangements.

Source: linoxide.com

Q3: Explain Blue-Green Deployment Technique ⭐⭐⭐

Answer: Blue-green deployment is a technique that reduces downtime and risk by running two identical production environments called Blue and Green. At any time, only one of the environments is live, with the live environment serving all production traffic. For this example, Blue is currently live and Green is idle.

As you prepare a new version of your software, deployment and the final stage of testing takes place in the environment that is not live: in this example, Green. Once you have deployed and fully tested the software in Green, you switch the router so all incoming requests now go to Green instead of Blue. Green is now live, and Blue is idle.

This technique can eliminate downtime due to application deployment. In addition, blue-green deployment reduces risk: if something unexpected happens with your new version on Green, you can immediately roll back to the last version by switching back to Blue.

Source: cloudfoundry.org

Q4: What's the difference between a blue/green deployment and a rolling deployment? ⭐⭐⭐

Answer:

  • In Blue Green Deployment, you have TWO complete environments. One is Blue environment which is running and the Green environment to which you want to upgrade. Once you swap the environment from blue to green, the traffic is directed to your new green environment. You can delete or save your old blue environment for backup until the green environment is stable.

  • In Rolling Deployment, you have only ONE complete environment. The code is deployed in the subset of instances of the same environment and moves to another subset after completion.

Source: stackoverflow.com

Q5: What are the differences between continuous integration, continuous delivery, and continuous deployment? ⭐⭐⭐

Answer:

  • Developers practicing continuous integration merge their changes back to the main branch as often as possible. By doing so, you avoid the integration hell that usually happens when people wait for release day to merge their changes into the release branch.
  • Continuous delivery is an extension of continuous integration to make sure that you can release new changes to your customers quickly in a sustainable way. This means that on top of having automated your testing, you also have automated your release process and you can deploy your application at any point of time by clicking on a button.
  • Continuous deployment goes one step further than continuous delivery. With this practice, every change that passes all stages of your production pipeline is released to your customers. There's no human intervention, and only a failed test will prevent a new change to be deployed to production.

Source: atlassian.com

Q6: What do you know about serverless model? ⭐⭐⭐

Answer: Serverless refers to a model where the existence of servers is hidden from developers. It means you no longer have to deal with capacity, deployments, scaling and fault tolerance and OS. It will essentially reducing maintenance efforts and allow developers to quickly focus on developing codes.

Examples are:

  • Amazon AWS Lambda
  • Azure Functions

Source: linoxide.com

Q7: How is container different from a virtual machine? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q8: What is Canary Releasing? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q9: What is Docker? ⭐

Answer:

  • Docker is a containerization platform which packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment be it development or test or production.
  • Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries etc. anything that can be installed on a server.
  • This guarantees that the software will always run the same, regardless of its environment.

Source: edureka.co

Q10: How virtualization works at low level? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q11: What is Paravirtualization? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q12: Define Microservice Architecture ⭐⭐

Answer: Microservices, aka Microservice Architecture, is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.

Source: lambdatest.com

Q13: What are the features of Microservices? ⭐⭐⭐

Answer:

  • Decoupling – Services within a system are largely decoupled. So the application as a whole can be easily built, altered, and scaled
  • Componentization – Microservices are treated as independent components that can be easily replaced and upgraded
  • Business Capabilities – Microservices are very simple and focus on a single capability
  • Autonomy – Developers and teams can work independently of each other, thus increasing speed
  • Continous Delivery – Allows frequent releases of software, through systematic automation of software creation, testing, and approval
  • Responsibility – Microservices do not focus on applications as projects. Instead, they treat applications as products for which they are responsible
  • Decentralized Governance – The focus is on using the right tool for the right job. That means there is no standardized pattern or any technology pattern. Developers have the freedom to choose the best useful tools to solve their problems
  • Agility – Microservices support agile development. Any new feature can be quickly developed and discarded again

Source: lambdatest.com

Q14: How does Microservice Architecture work? ⭐⭐⭐

Answer:

  • Clients – Different users from various devices send requests.
  • Identity Providers – Authenticates user or clients identities and issues security tokens.
  • API Gateway – Handles client requests.
  • Static Content – Houses all the content of the system.
  • Management –  Balances services on nodes and identifies failures.
  • Service Discovery – A guide to find the route of communication between microservices.
  • Content Delivery Networks – Distributed network of proxy servers and their data centers.
  • Remote Service – Enables the remote access information that resides on a network of IT devices.

Source: edureka.co

Q15: What is the difference between Monolithic, SOA and Microservices Architecture? ⭐⭐⭐

Answer:

  • Monolithic Architecture is similar to a big container wherein all the software components of an application are assembled together and tightly packaged.
  • A Service-Oriented Architecture is a collection of services which communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity.
  • Microservice Architecture is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.

Source: edureka.co

Q16: What are main differences between Microservices and Monolithic Architecture? ⭐⭐⭐

Answer: Microservices

  • Service Startup is fast
  • Microservices are loosely coupled architecture.
  • Changes done in a single data model does not affect other Microservices.
  • Microservices focuses on products, not projects

Monolithic Architecture

  • Service startup takes time
  • Monolithic architecture is mostly tightly coupled.
  • Any changes in the data model affect the entire database
  • Monolithic put emphasize over the whole project

Source: edureka.co

Q17: What are the standard patterns of orchestrating microservices? ⭐⭐⭐

Answer: As we start to model more and more complex logic, we have to deal with the problem of managing business processes that stretch across the boundary of individual services.

  • With orchestration, we rely on a central brain to guide and drive the process, much like the conductor in an orchestra. The orchestration style corresponds more to the SOA idea of orchestration/task services. For example we could wrap the business flow in its own service. Where the proxy orchestrates the interaction between the microservices like shown in the below picture.

  • With choreography, we inform each part of the system of its job, and let it work out the details, like dancers all find‐ ing their way and reacting to others around them in a ballet. The choreography style corresponds to the dumb pipes and smart endpoints mentioned by Martin Fowler's. That approach is also called the domain approach and is using domain events, where each service publish events regarding what have happened and other services can subscribe to those events.

Source: stackoverflow.com

Q18: What are smart endpoints and dumb pipes? ⭐⭐⭐

Answer:

  • Smart endpoints just meaning actual business rules and any other validations happens behind those endpoints which are not visible to anyone to the consumers of those endpoints think of it as a place where actual Magic happens.

  • Dumb pipelines means any communication means where no further actions e.g validations are taken place, it simply carries the data across that particular channel and it may also be replaceable if need be. The infrastructure chosen is typically dumb (dumb as in acts as a message router only). It just means that routing is the only function the pipes should be doing.

Source: stackoverflow.com

Q19: Whether do you find GraphQL the right fit for designing microservice architecture? ⭐⭐⭐

Answer: GraphQL and microservices are a perfect fit, because GraphQL hides the fact that you have a microservice architecture from the clients. From a backend perspective, you want to split everything into microservices, but from a frontend perspective, you would like all your data to come from a single API. Using GraphQL is the best way I know of that lets you do both. It lets you split up your backend into microservices, while still providing a single API to all your application, and allowing joins across data from different services.

Source: stackoverflow.com

Q20: What is Idempotence? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: What are the pros and cons of Microservice Architecture? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: What do you understand by Contract Testing? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: What is the role of an architect in Microservices architecture? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: Explain what is the API Gateway pattern ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Mention some benefits and drawbacks of an API Gateway ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: What is Materialized View pattern and when will you use it? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: What Did The Law Stated By Melvin Conway Implied? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: Name the main differences between SOA and Microservices? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: What is the difference between cohesion and coupling? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: What is a Consumer-Driven Contract (CDC)? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: What are Reactive Extensions in Microservices? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: What is the most accepted transaction strategy for microservices ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: Why would one use sagas over 2PC and vice versa? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q34: Provide an example of "smart pipes" and "dumb endpoint" ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q35: How would you implement SSO for Microservice Architecture? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 35 Top Angular 7 Interview Questions To Crack in 2019 | FullStack.Cafe

Q1: What are pipes? Give me an example. ⭐

Answer: A pipe takes in data as input and transforms it to a desired output. You can chain pipes together in potentially useful combinations. You can write your own custom pipes. Angular comes with a stock of pipes such as DatePipe, UpperCasePipe, LowerCasePipe, CurrencyPipe, and PercentPipe.

Consider:

<p>The hero's birthday is {{ birthday | date }}</p>

In this page, you'll use pipes to transform a component's birthday property into a human-friendly date.

Source: angular.io

Q2: What is the minimum definition of a component? ⭐⭐

Answer: The absolute minimal configuration for a @Component in Angular is a template. Both template properties are set to optional because you have to define either template or templateUrl.

When you don't define them, you will get an exception like this:

No template specified for component 'ComponentName'

A selector property is not required, as you can also use your components in a route.

Source: stackoverflow.com

Q3: What's the difference between an Angular component and module? ⭐⭐

Answer: Components control views (html). They also communicate with other components and services to bring functionality to your app.

Modules consist of one or more components. They do not control any html. Your modules declare which components can be used by components belonging to other modules, which classes will be injected by the dependency injector and which component gets bootstrapped. Modules allow you to manage your components to bring modularity to your app.

Source: stackoverflow.com

Q4: How can I select an element in a component template? ⭐⭐

Answer: You can get a handle to the DOM element via ElementRef by injecting it into your component's constructor:

constructor(myElement: ElementRef) { ... }

Source: medium.com

Q5: What is an observer? ⭐⭐

Answer: Observer is an interface for a consumer of push-based notifications delivered by an Observable. It has below structure,

    interface Observer<T> {
      closed?: boolean;
      next: (value: T) => void;
      error: (err: any) => void;
      complete: () => void;
    }

A handler that implements the Observer interface for receiving observable notifications will be passed as a parameter for observable as below,

    myObservable.subscribe(myObserver);

Note: If you don't supply a handler for a notification type, the observer ignores notifications of that type.

Source: github.com/sudheerj

Q6: What is an observable? ⭐⭐

Answer: An Observable is a unique Object similar to a Promise that can help manage async code. Observables are not part of the JavaScript language so we need to rely on a popular Observable library called RxJS. The observables are created using new keyword. Let see the simple example of observable,

    import { Observable } from 'rxjs';

    const observable = new Observable(observer => {
      setTimeout(() => {
        observer.next('Hello from a Observable!');
      }, 2000);
    });`

Source: github.com/sudheerj

Q7: What is TestBed? ⭐⭐⭐

Answer: The Angular Test Bed (ATB) is a higher level Angular Only testing framework that allows us to easily test behaviours that depend on the Angular Framework.

We still write our tests in Jasmine and run using Karma but we now have a slightly easier way to create components, handle injection, test asynchronous behaviour and interact with our application.

The TestBed creates a dynamically-constructed Angular test module that emulates an Angular @NgModule.

Source: angular.io

Q8: What is Redux and how does it relate to an Angular app? ⭐⭐⭐

Answer: Redux is a way to manage application state and improve maintainability of asynchronicity in your application by providing a single source of truth for the application state, and a unidirectional flow of data change in the application. ngrx/store is one implementation of Redux principles.

Source: github.com/WebPredict

Q9: What are the Core Dependencies of Angular 7? ⭐⭐⭐

Answer: There are two types of core dependencies, RxJS and TypeScript.

  • RxJS 6.3 - RxJS version 6.3 is used by Angular 7. It has no changes in the version from Angular 6

  • TypeScript 3.1 - TypeScript version 3.1 is used by Angular 7. It is the upgrade from the version 2.9 of Angular 6.

Source: onlineinterviewquestions.com

Q10: Why Incremental DOM Has Low Memory Footprint? ⭐⭐⭐

Answer: Virtual DOM creates a whole tree from scratch every time you rerender.

Incremental DOM, on the other hand, doesn’t need any memory to rerender the view if it doesn’t change the DOM. We only have to allocate the memory when the DOM nodes are added or removed. And the size of the allocation is proportional to the size of the DOM change.

Source: blog.nrwl.io

Q11: What are the ways to control AOT compilation? ⭐⭐⭐

Answer: You can control your app compilation in two ways

  1. By providing template compiler options in the tsconfig.json file
  2. By configuring Angular metadata with decorators

Source: github.com/sudheerj

Q12: What is activated route? ⭐⭐⭐

Answer: ActivatedRoute contains the information about a route associated with a component loaded in an outlet. It can also be used to traverse the router state tree. The ActivatedRoute will be injected as a router service to access the information. In the below example, you can access route path and parameters,

@Component({
    ...
 })
class MyComponent {
    constructor(route: ActivatedRoute) {
        const id: Observable < string > = route.params.pipe(map(p => p.id));
        const url: Observable < string > = route.url.pipe(map(segments => segments.join('')));
        // route.data includes both `data` and `resolve`
        const user = route.data.pipe(map(d => d.user));
    }
}

Source: github.com/sudheerj

Q13: What is router outlet? ⭐⭐⭐

Answer: The RouterOutlet is a directive from the router library and it acts as a placeholder that marks the spot in the template where the router should display the components for that outlet. Router outlet is used as a component,

    <router-outlet></router-outlet>
    <!-- Routed components go here -->

Source: github.com/sudheerj

Q14: What are the utility functions provided by RxJS? ⭐⭐⭐

Answer: The RxJS library also provides below utility functions for creating and working with observables.

  1. Converting existing code for async operations into observables
  2. Iterating through the values in a stream
  3. Mapping values to different types
  4. Filtering streams
  5. Composing multiple streams

Source: github.com/sudheerj

Q15: What is multicasting? ⭐⭐⭐

Answer: Multi-casting is the practice of broadcasting to a list of multiple subscribers in a single execution. Let's demonstrate the multi-casting feature,

    var source = Rx.Observable.from([1, 2, 3]);
    var subject = new Rx.Subject();
    var multicasted = source.multicast(subject);

    // These are, under the hood, `subject.subscribe({...})`:
    multicasted.subscribe({
      next: (v) => console.log('observerA: ' + v)
    });
    multicasted.subscribe({
      next: (v) => console.log('observerB: ' + v)
    });

    // This is, under the hood, `s

Source: github.com/sudheerj

Q16: What is subscribing? ⭐⭐⭐

Answer: An Observable instance begins publishing values only when someone subscribes to it. So you need to subscribe by calling the subscribe() method of the instance, passing an observer object to receive the notifications.

Let's take an example of creating and subscribing to a simple observable, with an observer that logs the received message to the console.

    Creates an observable sequence of 5 integers, starting from 1
    const source = range(1, 5);

    // Create observer object
    const myObserver = {
      next: x => console.log('Observer got a next value: ' + x),
      error: err => console.error('Observer got an error: ' + err),
      complete: () => console.log('Observer got a complete notification'),
    };

    // Execute with the observer object and Prints out each item
    myObservable.subscribe(myObserver);
    // => Observer got a next value: 1
    // => Observer got a next value: 2
    // => Observer got a next value: 3
    // => Observer got a next value: 4
    // => Observer got a next value: 5
    // => Observer got a complete notification

Source: github.com/sudheerj

Q17: How to set headers for every request in Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q18: Why would you use renderer methods instead of using native element methods? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q19: What is Zone in Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: What does a just-in-time (JIT) compiler do (in general)? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: What is ngUpgrage? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: Why would you use lazy loading modules in Angular app? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: What is Ivy Renderer? Is it supported by Angular 7? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: What is incremental DOM? How is it different from virtual DOM? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: What are the advantages with AOT? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: Do I need to bootstrap custom elements? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: What is the difference between pure and impure pipe? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: What is the difference between BehaviorSubject vs Observable? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: What is the Angular equivalent to an AngularJS "$watch"? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Name some differences between SystemJS vs WebPack? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation. Explain the difference. ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: Why angular uses url segment? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: Why did the Google team go with incremental DOM instead of virtual DOM? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q34: Why Incremental DOM is Tree Shakable? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q35: What's new in Angular 7? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 37 ASP.NET Interview Questions You Must Know | FullStack.Cafe

Q1: What is ViewData? ⭐

Answer: Viewdata contains the key, value pairs as dictionary and this is derived from class — “ViewDataDictionary“. In action method we are setting the value for viewdata and in view the value will be fetched by typecasting.

Source: medium.com

Q2: What is ASP.Net? ⭐

Answer: It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, XML etc.

Source: guru99.com

Q3: What is ASP.NET Core? ⭐⭐

Answer: ASP.NET Core is a brand new cross-platform web framework built with .NET Core framework. It is not an update to existing ASP.NET framework. It is a complete rewrite of the ASP.NET framework. It works with both .NET Core and .NET Framework.

Main characterestics of ASP.NET Core:

  • DI Container which is quite simple and built-in. You can extend it with other popular DI containers
  • Built-in and extensible structured logging. You can redirect output to as many sources as you want (file, Azure, AWS, console)
  • Extensible strongly typed configuration, which can also be used to reload at run-time
  • Kestrel – new, cross-platform and super fast web server which can stand alone without IIS, Nginx or Apache
  • New, fully async pipeline. It is easily configured via middleware
  • ASP.NET All meta package which improves development speed, and enables you to reference all Microsoft packages for ASP.NET Core and it will deploy only those that are being used by your code
  • There is no web.config. We now use appsettings.json file in combination with other sources of configuration (command line args, environment variables, etc.)
  • There is no _Global._asax – We have Startup.cs which is used to set up Middleware and services for DI Container.

Source: talkingdotnet.com

Q4: Can ASP.NET Core work with the .NET framework? ⭐⭐

Answer: Yes. This might surprise many, but ASP.NET Core works with .NET framework and this is officially supported by Microsoft.

ASP.NET Core works with:

  • .NET Core framework
  • .NET framework

Source: talkingdotnet.com

Q5: Explain startup process in ASP.NET Core? ⭐⭐

Answer: Everything starts from Program.cs

public static void Main(string[] args)
{
    BuildWebHost(args).Run();
}
 
public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .Build();

CreateDefaultBuilder extension method will create a default configuration which will look first into appsettings.json files then will look for Environment variables and at the end, it will use command line arguments.

This part will also set up default logger sources (debug and console) and load the settings for logging from appsettings.json.

After the CreateDefaultBuilder finishes, then Startup class is executed. First, the constructor code is executed. After that, services are added to DI container via AddServices method that lives in Startup class. After that, an order of middleware that will handle every incoming request is set up.

Source: codingblast.com

Q6: What is the difference between ASP.NET and ASP.NET MVC? ⭐⭐

Answer: ASP.NET, at its most basic level, provides a means for you to provide general HTML markup combined with server side "controls" within the event-driven programming model that can be leveraged with VB, C#, and so on. You define the page(s) of a site, drop in the controls, and provide the programmatic plumbing to make it all work.

ASP.NET MVC is an application framework based on the Model-View-Controller architectural pattern. This is what might be considered a "canned" framework for a specific way of implementing a web site, with a page acting as the "controller" and dispatching requests to the appropriate pages in the application. The idea is to "partition" the various elements of the application, eg business rules, presentation rules, and so on.

Think of the former as the "blank slate" for implementing a site architecture you've designed more or less from the ground up. MVC provides a mechanism for designing a site around a pre-determined "pattern" of application access, if that makes sense. There's more technical detail to it than that, to be sure, but that's the nickel tour for the purposes of the question.

Source: stackoverflow.com

Q7: What is a postback? ⭐⭐

Answer: A postback originates from the client browser. Usually one of the controls on the page will be manipulated by the user (a button clicked or dropdown changed, etc), and this control will initiate a postback. The state of this control, plus all other controls on the page (known as the View State) is Posted Back to the web server.

Source: stackoverflow.com

Q8: What is ViewState? ⭐⭐

Answer: View State is the method to preserve the Value of the Page and Controls between round trips. It is a Page-Level State Management technique. View State is turned on by default and normally serializes the data in every control on the page regardless of whether it is actually used during a post-back.

A web application is stateless. That means that a new instance of a page is created every time when we make a request to the server to get the page and after the round trip our page has been lost immediately

Source: c-sharpcorner.com

Q9: What exactly is an application pool? What is its purpose? ⭐⭐

Answer: Application pools allow you to isolate your applications from one another, even if they are running on the same server. This way, if there is an error in one app, it won't take down other applications.

Additionally, applications pools allow you to separate different apps which require different levels of security.

Source: stackoverflow.com

Q10: Explain Middleware in ASP.NET Core? ⭐⭐⭐

Answer: Middleware is actually sequential series of delegates (piece of code), that can either short-circuit or pass on the HTTP request to next delegate. These are known as middleware, a concept well known to people who worked with Node.js.

Piece of your middleware can do one of the following:

  • Handle an incoming HTTP request by generating an HTTP response (maybe your authentication or authorization middleware will stop the request early and immediately create response)
  • Process the incoming request, change it and pass it to the next middleware in the pipeline
  • Process the outgoing response, change it and pass it on to next middleware in the pipeline or directly to the ASP.NET Core web server

Source: talkingdotnet.com

Q11: What are the different types of caching? ⭐⭐⭐

Answer: ASP.NET has 3 kinds of caching :

  1. Output Caching,
  2. Fragment Caching,
  3. Data Caching.

Source: guru99.com

Q12: How long the items in ViewState exists? ⭐⭐⭐

Answer: They exist for the life of the current page.

Source: guru99.com

Q13: In which event of page cycle is the ViewState available? ⭐⭐⭐

Answer: After the Init() and before the Page_Load().

Source: guru99.com

Q14: What are the sub types of ActionResult? ⭐⭐⭐

Answer: ActionResult is used to represent the action method result. Below are the subtypes of ActionResult:

  • ViewResult
  • PartialViewResult
  • RedirectToRouteResult
  • RedirectResult
  • JavascriptResult
  • JSONResult
  • FileResult
  • HTTPStatusCodeResult

Source: medium.com

Q15: What is the difference between Server.Transfer and Response.Redirect? ⭐⭐⭐

Answer: In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.

Response.Redirect is used to redirect the user's browser to another page or site. It performs trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

Source: guru99.com

Q16: How can we prevent browser from caching an ASPX page? ⭐⭐⭐

Answer: We can SetNoStore on HttpCachePolicy object exposed by the Response object's Cache property:

Response.Cache.SetNoStore();
Response.Write(DateTime.Now.ToLongTimeString ());

Source: guru99.com

Q17: What are the event handlers that we can have in Global.asax file? ⭐⭐⭐

Answer:

  • Application Events: Application_Start , Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache

  • Session Events: Session_Start,Session_End

Source: guru99.com

Q18: In which event are the controls fully loaded? ⭐⭐⭐

Answer: Page load event.

Source: guru99.com

Q19: What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? ⭐⭐⭐

Answer: View state is a kind of hash map (or at least you can think of it that way) that ASP.NET uses to store all the temporary information about a page - like what options are currently chosen in each select box, what values are there in each text box, which panel are open, etc. You can also use it to store any arbitrary information.

The entire map is serialized and encoded and kept in a hidden variable (__VIEWSTATE form field) that's posted back to the server whenever you take any action on the page that requires a server round trip. This is how you can access the values on the controls from the server code. If you change any value in the server code, that change is made in the view state and sent back to the browser.

Just be careful about how much information you store in the view state, though... it can quickly become bloated and slow to transfer each time to the server and back.

It's not encrypted at all. Just base encoded, which easily reversible.

Source: stackoverflow.com

Q20: What exactly is the difference between .NET Core and ASP.NET Core? ⭐⭐⭐

Answer: .NET Core is a runtime. It can execute applications that are built for it.

ASP.NET Core is a collection of libraries that form a Framework for building web applications. ASP.NET Core libraries can be used on both .NET Core and the "Full .NET Framework" (what has shipped with windows for many years).

Source: stackoverflow.com

Q21: What are the different Session state management options available in ASP.NET? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: What is the difference between web config and machine config? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: List the major built-in objects in ASP.NET? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: What are the different types of cookies in ASP.NET? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: What is Katana? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: How to choose between ASP.NET 4.x and ASP.NET Core? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: What is an HttpHandler in ASP.NET? Why and how is it used? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: What is the difference between <system.web> and <system.webServer>? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: What is HttpModule in ASP.Net? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Name some ASP.NET WebForms disadvantages over MVC? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: What exactly is OWIN and what problems does it solve? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: Are static class instances unique to a request or a server in ASP.NET? ⭐⭐⭐⭐⭐

Details: On an ASP.NET website, are static classes unique to each web request, or are they instantiated whenever needed and GCed whenever the GC decides to disposed of them?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: What are the Advantages of Using ASP.NET Web API? ⭐⭐

Answer: Using ASP.NET Web API has a number of advantages, but core of the advantages are:

  • It works the HTTP way using standard HTTP verbs like GET, POST, PUT, DELETE, etc. for all CRUD operations
  • Complete support for routing
  • Response generated in JSON or XML format using MediaTypeFormatter
  • It has the ability to be hosted in IIS as well as self-host outside of IIS
  • Supports Model binding and Validation
  • Support for OData

Source: codeproject.com

Q34: Compare WCF vs ASP.NET Web API? ⭐⭐⭐

Answer:

  • Windows Communication Foundation is designed to exchange standard SOAP-based messages using variety of transport protocols like HTTP, TCP, NamedPipes or MSMQ, etc.
  • On the other hand, ASP.NET API is a framework for building non-SOAP based services over HTTP only.

Source: codeproject.com

Q35: What's the difference between REST & RESTful? ⭐⭐⭐

Answer:

  • Representational state transfer (REST) is a style of software architecture. As described in a dissertation by Roy Fielding, REST is an "architectural style" that basically exploits the existing technology and protocols of the Web.
  • RESTful is typically used to refer to web services implementing such an architecture.

Source: stackoverflow.com

Q36: What's the difference between OpenID and OAuth? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q37: Explain the difference between WCF, Web API, WCF REST and Web Service? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 39 Advanced React Interview Questions You Must Clarify (2020 Update) | FullStack.Cafe

Q1: What is virtual DOM? ⭐

Answer: The virtual DOM (VDOM) is an in-memory representation of Real DOM. The representation of a UI is kept in memory and synced with the “real” DOM. It’s a step that happens between the render function being called and the displaying of elements on the screen. This entire process is called reconciliation.

Source: github.com/sudheerj

Q2: What are the differences between a class component and functional component? ⭐⭐

Answer:

  • Class components allows you to use additional features such as local state and lifecycle hooks. Also, to enable your component to have direct access to your store and thus holds state.

  • When your component just receives props and renders them to the page, this is a stateless component, for which a pure function can be used. These are also called dumb components or presentational components.

Source: github.com/Pau1fitz

Q3: What are refs used for in React? ⭐⭐

Answer: Refs are an escape hatch which allow you to get direct access to a DOM element or an instance of a component. In order to use them you add a ref attribute to your component whose value is a callback function which will receive the underlying DOM element or the mounted instance of the component as its first argument.

class UnControlledForm extends Component {
  handleSubmit = () => {
    console.log("Input Value: ", this.input.value)
  }
  render () {
    return (
      <form onSubmit={this.handleSubmit}>
        <input
          type='text'
          ref={(input) => this.input = input} />
        <button type='submit'>Submit</button>
      </form>
    )
  }
}

Above notice that our input field has a ref attribute whose value is a function. That function receives the actual DOM element of input which we then put on the instance in order to have access to it inside of the handleSubmit function.

It’s often misconstrued that you need to use a class component in order to use refs, but refs can also be used with functional components by leveraging closures in JavaScript.

function CustomForm ({handleSubmit}) {
  let inputElement
  return (
    <form onSubmit={() => handleSubmit(inputElement.value)}>
      <input
        type='text'
        ref={(input) => inputElement = input} />
      <button type='submit'>Submit</button>
    </form>
  )
}

Source: github.com/Pau1fitz

Q4: Describe how events are handled in React. ⭐⭐

Answer: In order to solve cross browser compatibility issues, your event handlers in React will be passed instances of SyntheticEvent, which is React’s cross-browser wrapper around the browser’s native event. These synthetic events have the same interface as native events you’re used to, except they work identically across all browsers.

What’s mildly interesting is that React doesn’t actually attach events to the child nodes themselves. React will listen to all events at the top level using a single event listener. This is good for performance and it also means that React doesn’t need to worry about keeping track of event listeners when updating the DOM.

Source: tylermcginnis.com

Q5: What is the difference between state and props? ⭐⭐

Answer: Both props and state are plain JavaScript objects. While both of them hold information that influences the output of render, they are different in their functionality with respect to component. i.e,

  • Props get passed to the component similar to function parameters
  • state is managed within the component similar to variables declared within a function.

Source: https://github.com/sudheerj

Q6: How to create refs? ⭐⭐

Answer: Refs are created using React.createRef() method and attached to React elements via the ref attribute. In order to use refs throughout the component, just assign the ref to the instance property with in constructor.

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.myRef = React.createRef();
  }
  render() {
    return <div ref={this.myRef} />;
  }
}

And:

class UserForm extends Component {
  handleSubmit = () => {
    console.log("Input Value is: ", this.input.value)
  }
  render () {
    return (
      <form onSubmit={this.handleSubmit}>
        <input
          type='text'
          ref={(input) => this.input = input} /> // Access DOM input in handle submit
        <button type='submit'>Submit</button>
      </form>
    )
  }
}

We can also use it in functional components with the help of closures.

Source: github.com/sudheerj

Q7: What are Higher-Order components? ⭐⭐

Answer: A higher-order component (HOC) is a function that takes a component and returns a new component. Basically, it’s a pattern that is derived from React’s compositional nature We call them as “pure’ components” because they can accept any dynamically provided child component but they won’t modify or copy any behavior from their input components.

const EnhancedComponent = higherOrderComponent(WrappedComponent);

HOC can be used for many use cases as below,

  1. Code reuse, logic and bootstrap abstraction
  2. Render High jacking
  3. State abstraction and manipulation
  4. Props manipulation

Source: github.com/sudheerj

Q8: What is the purpose of using super constructor with props argument? ⭐⭐

Answer: A child class constructor cannot make use of this reference until super() method has been called. The same applies for ES6 sub-classes as well. The main reason of passing props parameter to super() call is to access this.props in your child constructors.

Passing props:

class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        console.log(this.props);  // Prints { name: 'sudheer',age: 30 }
    }
}

Not passing props:

class MyComponent extends React.Component {
    constructor(props) {
        super();
        console.log(this.props); // Prints undefined
        // But Props parameter is still available
        console.log(props); // Prints { name: 'sudheer',age: 30 }
    }

    render() {
        // No difference outside constructor
        console.log(this.props) // Prints { name: 'sudheer',age: 30 }
    }
}

The above code snippets reveals that this.props behavior is different only with in the constructor. It would be same outside the constructor.

Source: github.com/sudheerj

Q9: What are controlled components? ⭐⭐⭐

Answer: In HTML, form elements such as <input>, <textarea>, and <select> typically maintain their own state and update it based on user input. When a user submits a form the values from the aforementioned elements are sent with the form. With React it works differently. The component containing the form will keep track of the value of the input in it's state and will re-render the component each time the callback function e.g. onChange is fired as the state will be updated. An input form element whose value is controlled by React in this way is called a controlled component.

Source: github.com/Pau1fitz

Q10: What is equivalent of the following using React.createElement? ⭐⭐⭐

Answer: Question:

const element = (
  <h1 className="greeting">
    Hello, world!
  </h1>
);

What is equivalent of the following using React.createElement?

Answer:

const element = React.createElement(
  'h1',
  {className: 'greeting'},
  'Hello, world!'
);

Source: github.com/Pau1fitz

Q11: What can you tell me about JSX? ⭐⭐⭐

Answer: When Facebook first released React to the world, they also introduced a new dialect of JavaScript called JSX that embeds raw HTML templates inside JavaScript code. JSX code by itself cannot be read by the browser; it must be transpiled into traditional JavaScript using tools like Babel and webpack. While many developers understandably have initial knee-jerk reactions against it, JSX (in tandem with ES2015) has become the defacto method of defining React components.

class MyComponent extends React.Component {
  render() {
    let props = this.props;  
    return (
      <div className="my-component">
      <a href={props.url}>{props.name}</a>
      </div>
    );
  }
}

Source: codementor.io

Q12: Given the code defined above, can you identify two problems? ⭐⭐⭐

Answer: Take a look at the code below:

class MyComponent extends React.Component {
  constructor(props) {
    // set the default internal state
    this.state = {
      clicks: 0
    };
  }

  componentDidMount() {
    this.refs.myComponentDiv.addEventListener('click', this.clickHandler);
  }

  componentWillUnmount() {
    this.refs.myComponentDiv.removeEventListener('click', this.clickHandler);
  }

  clickHandler() {
    this.setState({
      clicks: this.clicks + 1
    });
  }

  render() {
    let children = this.props.children;

    return (
      <div className="my-component" ref="myComponentDiv">
      <h2>My Component ({this.state.clicks} clicks})</h2>
      <h3>{this.props.headerText}</h3>
    {children}
    </div>
    );
  }
}

Given the code defined above, can you identify two problems?

Answer:

  1. The constructor does not pass its props to the super class. It should include the following line:
constructor(props) {
  super(props);
  // ...
}
  1. The event listener (when assigned via addEventListener()) is not properly scoped because ES2015 doesn’t provide autobinding. Therefore the developer can re-assign clickHandler in the constructor to include the correct binding to this:
constructor(props) {
  super(props);
  this.clickHandler = this.clickHandler.bind(this);
  // ...
}

Source: codementor.io

Q13: Why should not we update the state directly? ⭐⭐⭐

Answer: If you try to update state directly then it won’t re-render the component.

    //Wrong
    This.state.message =”Hello world”;

Instead use setState() method. It schedules an update to a component’s state object. When state changes, the component responds by re-rendering

    //Correct
    This.setState({message: ‘Hello World’});

Note: The only place you can assign the state is constructor.

Source: https://github.com/sudheerj

Q14: What are the different phases of ReactJS component lifecycle? ⭐⭐⭐

Answer: There are four different phases of React component’s lifecycle:

  1. Initialization: In this phase react component prepares setting up the initial state and default props.
  2. Mounting: The react component is ready to mount in the browser DOM. This phase covers componentWillMount and componentDidMount lifecycle methods.
  3. Updating: In this phase, the component get updated in two ways, sending the new props and updating the state. This phase covers shouldComponentUpdate, componentWillUpdate and componentDidUpdate lifecycle methods.
  4. Unmounting: In this last phase, the component is not needed and get unmounted from the browser DOM. This phase include componentWillUnmount lifecycle method.

Source: github.com/sudheerj

Q15: What are the lifecycle methods of ReactJS? ⭐⭐⭐

Answer:

  • componentWillMount: Executed before rendering and is used for App level configuration in your root component.
  • componentDidMount: Executed after first rendering and here all AJAX requests, DOM or state updates, and set up eventListeners should occur.
  • componentWillReceiveProps: Executed when particular prop updates to trigger state transitions.
  • shouldComponentUpdate: Determines if the component will be updated or not. By default it returns true. If you are sure that the component doesn't need to render after state or props are updated, you can return false value. It is a great place to improve performance as it allows you to prevent a rerender if component receives new prop.
  • componentWillUpdate: Executed before re-rendering the component when there are pros & state changes confirmed by shouldComponentUpdate which returns true.
  • componentDidUpdate: Mostly it is used to update the DOM in response to prop or state changes.
  • componentWillUnmount: It will be used to cancel any outgoing network requests, or remove all event listeners associated with the component.

Source: github.com/sudheerj

Q16: What do these three dots (...) in React do? ⭐⭐⭐

Details: What does the ... do in this React (using JSX) code and what is it called?

<Modal {...this.props} title='Modal heading' animation={fal

Answer: That's property spread notation. It was added in ES2018 (spread for arrays/iterables was earlier, ES2015).

For instance, if this.props contained a: 1 and b: 2, then

<Modal {...this.props} title='Modal heading' animation={false}>

would be the same as:

<Modal a={this.props.a} b={this.props.b} title='Modal heading' animation={false}>

Spread notation is handy not only for that use case, but for creating a new object with most (or all) of the properties of an existing object — which comes up a lot when you're updating state, since you can't modify state directly:

this.setState(prevState => {
    return {foo: {...prevState.foo, a: "updated"}};
});

Source: stackoverflow.com

Q17: What are advantages of using React Hooks? ⭐⭐⭐

Answer: Primarily, hooks in general enable the extraction and reuse of stateful logic that is common across multiple components without the burden of higher order components or render props. Hooks allow to easily manipulate the state of our functional component without needing to convert them into class components.

Hooks don’t work inside classes (because they let you use React without classes). By using them, we can totally avoid using lifecycle methods, such as componentDidMount, componentDidUpdate, componentWillUnmount. Instead, we will use built-in hooks like useEffect .

Source: hackernoon.com

Q18: What are React Hooks? ⭐⭐⭐

Answer: Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. With Hooks, you can extract stateful logic from a component so it can be tested independently and reused. Hooks allow you to reuse stateful logic without changing your component hierarchy. This makes it easy to share Hooks among many components or with the community.

Source: reactjs.org

Q19: What is useState() in React? ⭐⭐⭐

Details: Explain what is the use of useState(0) there:

...
const [count, setCounter] = useState(0);
const [moreStuff, setMoreStuff] = useState(...);
...

const setCount = () => {
    setCounter(count + 1);
    setMoreStuff(...);
    ...
};

Answer: useState is one of build-in react hooks. useState(0) returns a tuple where the first parameter count is the current state of the counter and setCounter is the method that will allow us to update the counter's state.

We can use the setCounter method to update the state of count anywhere - In this case we are using it inside of the setCount function where we can do more things; the idea with hooks is that we are able to keep our code more functional and avoid class based components if not desired/needed.

Source: stackoverflow.com

Q20: What is StrictMode in React? ⭐⭐⭐

Answer: React's StrictMode is sort of a helper component that will help you write better react components, you can wrap a set of components with <StrictMode /> and it'll basically:

  • Verify that the components inside are following some of the recommended practices and warn you if not in the console.
  • Verify the deprecated methods are not being used, and if they're used strict mode will warn you in the console.
  • Help you prevent some side effects by identifying potential risks.

Source: stackoverflow.com

Q21: Why do class methods need to be bound to a class instance? ⭐⭐⭐

Answer: In JavaScript, the value of this changes depending on the current context. Within React class component methods, developers normally expect this to refer to the current instance of a component, so it is necessary to bind these methods to the instance. Normally this is done in the constructor—for example:

class SubmitButton extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isFormSubmitted: false
    };
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleSubmit() {
    this.setState({
      isFormSubmitted: true
    });
  }

  render() {
    return (
      <button onClick={this.handleSubmit}>Submit</button>
    )
  }
}

Source: toptal.com

Q22: What is prop drilling and how can you avoid it? ⭐⭐⭐

Answer: When building a React application, there is often the need for a deeply nested component to use data provided by another component that is much higher in the hierarchy. The simplest approach is to simply pass a prop from each component to the next in the hierarchy from the source component to the deeply nested component. This is called prop drilling.

The primary disadvantage of prop drilling is that components that should not otherwise be aware of the data become unnecessarily complicated and are harder to maintain.

To avoid prop drilling, a common approach is to use React context. This allows a Provider component that supplies data to be defined, and allows nested components to consume context data via either a Consumer component or a useContext hook.

Source: toptal.com

Q23: Describe Flux vs MVC? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: What is the difference between a controlled component and an uncontrolled component? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: What is wrong with this code? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: What is the React context? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: What is React Fiber? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: How to apply validation on Props in ReactJS? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: What is the difference between ReactJS and Angular? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: What is the difference between using constructor vs getInitialState in React? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: When is it important to pass props to super(), and why? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: How to conditionally add attributes to React components? ⭐⭐⭐⭐

Details: Is there a way to only add attributes to a React component if a certain condition is met?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: Do Hooks replace render props and higher-order components? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q34: How would you go about investigating slow React application rendering? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q35: When would you use StrictMode component in React? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q36: What is a pure function? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q37: How does React renderer work exactly when we call setState? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q38: What is the key architectural difference between a JavaScript library such as React and a JavaScript framework such as Angular? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q39: How to avoid the need for binding in React? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 40 Advanced OOP Interview Questions and Answers [2019 Update] | FullStack.Cafe

Q1: What is inheritance? ⭐

Answer: Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and speeds up implementation time.

When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class.

The idea of inheritance implements the IS-A relationship. For example, mammal IS A animal, dog IS-A mammal hence dog IS-A animal as well, and so on.

Source: tutorialspoint.com

Q2: What is object-oriented programming (OOP)? ⭐

Answer: OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object is created in the program to represent a class. Therefore, an object encapsulates all the features, such as data and behavior that are associated to a class. OOP allows developers to develop modular programs and assemble them as software. Objects are used to access data and behaviors of different software modules, such as classes, namespaces, and sharable assemblies. .NET Framework supports only OOP languages, such as Visual Basic .NET, Visual C#, and Visual C++.

Source: indiabix.com

Q3: What is encapsulation? ⭐⭐

Answer: Encapsulation is defined as the process of enclosing one or more items within a physical or logical package. Encapsulation, in object oriented programming methodology, prevents access to implementation details.

Source: tutorialspoint.com

Q4: What is polymorphism? ⭐⭐

Answer: The word polymorphism means having many forms. In object-oriented programming paradigm, polymorphism is often expressed as one interface, multiple functions.

Source: tutorialspoint.com

Q5: What is the difference between procedural and object-oriented programming? ⭐⭐

Answer: Procedural programming is based upon the modular approach in which the larger programs are broken into procedures. Each procedure is a set of instructions that are executed one after another. On the other hand, OOP is based upon objects. An object consists of various elements, such as methods and variables.

Access modifiers are not used in procedural programming, which implies that the entire data can be accessed freely anywhere in the program. In OOP, you can specify the scope of a particular data by using access modifiers - public, private, internal, protected, and protected internal.

Source: indiabix.com

Q6: Explain the concept of constructor? ⭐⭐

Answer: Constructor is a special method of a class, which is called automatically when the instance of a class is created. It is created with the same name as the class and initializes all class members, whenever you access the class. The main features of a constructor are as follows:

  • Constructors do not have any return type.
  • Constructors can be overloaded.
  • It is not mandatory to declare a constructor; it is invoked automatically by .NET Framework.

Source: indiabix.com

Q7: Why is the virtual keyword used in code? ⭐⭐

Answer: The virtual keyword is used while defining a class to specify that the methods and the properties of that class can be overridden in derived classes.

Source: indiabix.com

Q8: What is the difference between a class and a structure? ⭐⭐

Answer: Class:

  • A class is a reference type.
  • While instantiating a class, CLR allocates memory for its instance in heap.
  • Classes support inheritance.
  • Variables of a class can be assigned as null.
  • Class can contain constructor/destructor.

Structure:

  • A structure is a value type.
  • In structure, memory is allocated on stack.
  • Structures do not support inheritance.
  • Structure members cannot have null values.
  • Structure does not require constructor/destructor and members can be initialiazed automatically.

Source: indiabix.com

Q9: What is the relationship between a class and an object? ⭐⭐

Answer: A class acts as a blue-print that defines the properties, states, and behaviors that are common to a number of objects. An object is an instance of the class. For example, you have a class called Vehicle and Car is the object of that class. You can create any number of objects for the class named Vehicle, such as Van, Truck, and Auto.

The new operator is used to create an object of a class. When an object of a class is instantiated, the system allocates memory for every data member that is present in the class.

Source: indiabix.com

Q10: When should I use a struct instead of a class? ⭐⭐⭐

Answer: Do not define a structure unless the type has all of the following characteristics:

  • It logically represents a single value, similar to primitive types (integer, double, and so on).
  • It has an instance size smaller than 16 bytes.
  • It is immutable.
  • It will not have to be boxed frequently.

Source: stackoverflow.com

Q11: What is polymorphism, what is it for, and how is it used? ⭐⭐⭐

Answer: Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.

The beauty of polymorphism is that the code working with the different classes does not need to know which class it is using since they’re all used the same way. A real world analogy for polymorphism is a button. Everyone knows how to use a button: you simply apply pressure to it. What a button “does,” however, depends on what it is connected to and the context in which it is used — but the result does not affect how it is used. If your boss tells you to press a button, you already have all the information needed to perform the task.

Source: stackoverflow.com

Q12: What do you mean by data encapsulation? ⭐⭐⭐

Answer: Data encapsulation is a concept of binding data and code in single unit called object and hiding all the implementation details of a class from the user. It prevents unauthorized access of data and restricts the user to use the necessary data only.

Source: indiabix.com

Q13: What are abstract classes? What are the distinct characteristics of an abstract class? ⭐⭐⭐

Answer: An abstract class is a class that cannot be instantiated and is always used as a base class.
The following are the characteristics of an abstract class:

  • You cannot instantiate an abstract class directly. This implies that you cannot create an object of the abstract class; it must be inherited.
  • You can have abstract as well as non-abstract members in an abstract class.
  • You must declare at least one abstract method in the abstract class.
  • An abstract class is always public.
  • An abstract class is declared using the abstract keyword.

The basic purpose of an abstract class is to provide a common definition of the base class that multiple derived classes can share.

Source: indiabix.com

Q14: What are similarities between a class and a structure? ⭐⭐⭐

Answer: The following are some of the similarities between a class and a structure:

  • Access specifiers, such as public, private, and protected, are identically used in structures and classes to restrict the access of their data and methods outside their body.
  • The access level for class members and struct members, including nested classes and structs, is private by default. Private nested types are not accessible from outside the containing type.
  • Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers.
  • Both structures and classes can implement interfaces to use multiple-inheritance in code.
  • Both structures and classes can have constructors with parameter.
  • Both structures and classes can have delegates and events.

Source: indiabix.com

Q15: How can you prevent a class from overriding in C#? ⭐⭐⭐

Answer: You can prevent a class from overriding in C# by using the sealed keyword.

Source: indiabix.com

Q16: How is method overriding different from method overloading? ⭐⭐⭐

Answer:

  • Overriding involves the creation of two or more methods with the same name and same signature in different classes (one of them should be parent class and other should be child).
  • Overloading is a concept of using a method at different places with same name and different signatures within the same class.

Source: indiabix.com

Q17: Can you specify the accessibility modifier for methods inside the interface? ⭐⭐⭐

Answer: All the methods inside an interface are always public, by default. You cannot specify any other access modifier for them.

Source: indiabix.com

Q18: Is it possible for a class to inherit the constructor of its base class? ⭐⭐⭐

Answer: No, a class cannot inherit the constructor of its base class.

Source: indiabix.com

Q19: What is the difference between cohesion and coupling? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: What's the advantage of using getters and setters - that only get and set - instead of simply using public fields for those variables? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: What exactly is the difference between an interface and abstract class? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: What is Coupling in OOP? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: What is Cohesion in OOP? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: Explain the concept of destructor? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Differentiate between an abstract class and an interface. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: What is a static constructor? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: Explain different types of inheritance. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: Does .NET support multiple inheritance? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: Can you declare an overridden method to be static if the original method is not static? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Why Doesn't C# Allow Static Methods to Implement an Interface? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: What is the difference between a mixin and inheritance? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: In terms that an OOP programmer would understand (without any functional programming background), what is a monad? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: What is LSP (Liskov Substitution Principle) and what are some examples of its use (good and bad)? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q34: Could you elaborate Polymorphism vs Overriding vs Overloading? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q35: What does it mean to “program to an interface”? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q36: Can you provide a simple explanation of methods vs. functions in OOP context? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q37: Why prefer composition over inheritance? What trade-offs are there for each approach? When should you choose inheritance over composition? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q38: What is the difference between association, aggregation and composition? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q39: Can you declare a private class in a namespace? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q40: You have defined a destructor in a class that you have developed by using the C# programming language, but the destructor never executed. Why did the destructor not execute? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 40 Common ADO.NET Interview Questions to Know in 2019 | FullStack.Cafe

Q1: What is ADO.NET? ⭐

Answer: ADO stands for Active Data Object and ADO.NET is a set of .NET libraries for ADO. NET is a collection of managed libraries used by .NET applications for data source communication using a driver or provider:

  • Enterprise applications handle a large amount of data. This data is primarily stored in relational databases, such as Oracle, SQL Server, and Access and so on. These databases use Structured Query Language (SQL) for retrieval of data.
  • To access enterprise data from a .NET application, an interface was needed. This interface acts as a bridge between an RDBMS system and a .NET application. ADO.NET is such an interface that is created to connect .NET applications to RDBMS systems.
  • In the .NET framework, Microsoft introduced a new version of Active X Data Objects (ADO) called ADO.NET. Any .NET application, either Windows based or web based, can interact with the database using a rich set of classes of the ADO.NET library. Data can be accessed from any database using connected or disconnected architecture.

Source: c-sharpcorner.com

Q2: What do you understand by DataRelation class? ⭐⭐

Answer: The DataRelation is a class of disconnected architecture in the .NET framework. It is found in the System.Data namespace. It represents a relationship between database tables and correlates tables on the basis of matching column.

Source: c-sharpcorner.com

Q3: Describe when you would use the DataView in ADO.NET? ⭐⭐

Answer: A DataView enables you to create different views of the data stored in a DataTable, a capability that is often used in data binding applications. Using a DataView, you can expose the data in a table with different sort orders, and you can filter the data by row state or based on a filter expression. A DataView provides a dynamic view of data whose content, ordering, and membership reflect changes to the underlying DataTable as they occur. This is different from the Select method of the DataTable, which returns a DataRow array from a table per particular filter and/or sort order and whose content reflects changes to the underlying table, but whose membership and ordering remain static. The dynamic capabilities of the DataView make it ideal for data-binding applications.

Source: stackoverflow.com

Q4: What is the SqlCommandBuilder? ⭐⭐

Answer: CommandBuilder helps you to generate update, delete, and insert commands on a single database table for a data adapter. Similar to other objects, each data provider has a command builder class. The OleDbCommandBuilder, SqlCommonBuilder, and OdbcCommandBuilder classes represent the CommonBuilder object in the OleDb, Sql, and ODBC data providers.

Source: c-sharpcorner.com

Q5: What is the basic difference between ADO.NET and Entity Framework? ⭐⭐

Answer: ADO.NET Entity Framework is an ORM (object-relational mapping) which creates a higher abstract object model over ADO.NET components. ADO.NET is a layer closer to the database (datatables, datasets and etc...). The main and the only benefit of EF is it auto-generates code for the Model (middle layer), Data Access Layer, and mapping code, thus reducing a lot of development time. Consider the following example:

ADO.NET:

DataTable table = adoDs.Tables[0];
for (int j = 0; j < table.Rows.Count; j++)
{
    DataRow row = table.Rows[j];

    // Get the values of the fields
    string CustomerName =
        (string)row["Customername"];
    string CustomerCode =
        (string)row["CustomerCode"];
}

EF:

foreach (Customer objCust in obj.Customers)
{}

Source: stackoverflow.com

Q6: What is SqlCommand Object? ⭐⭐

Answer: The SqlCommand carries the SQL statement that needs to be executed on the database. SqlCommand carries the command in the CommandText property and this property will be used when the SqlCommand calls any of its execute methods.

  • The Command Object uses the connection object to execute SQL queries.
  • The queries can be in the form of Inline text, Stored Procedures or direct Table access.
  • An important feature of Command object is that it can be used to execute queries and Stored Procedures with Parameters.
  • If a select query is issued, the result set it returns is usually stored in either a DataSet or a DataReader object.

The three important methods exposed by the SqlCommand object is shown below:

  • ExecuteScalar
  • ExecuteNonQuery
  • ExecuteReader

Source: c-sharpcorner.com

Q7: What is Connection Pooling in ADO.NET? ⭐⭐

Answer: ADO.NET uses a technique called connection pooling, which minimizes the cost of repeatedly opening and closing connections. Connection pooling reuses existing active connections with the same connection string instead of creating new connections when a request is made to the database. It involves the use of a connection manager that is responsible for maintaining a list, or pool, of available connections for a given connection string. Several pools exist if different connection strings ask for connection pooling.

Source: c-sharpcorner.com

Q8: How can you define the DataSet structure? ⭐⭐

Answer: A DataSet object falls in disconnected components series. The DataSet consists of a collection of tables, rows, columns and relationships.

DataSet contains a collection of DataTables and the DataTable contains a collection of DataRows, DataRelations, and DataColumns. A DataTable maps to a table in the database.

Source: c-sharpcorner.com

Q9: What are the ADO.NET components? ⭐⭐

Answer: ADO.NET components categorized in three modes:

  • disconnected,
  • common or shared and
  • the .NET data providers.

The disconnected components build the basic ADO.NET architecture. You can use these components (or classes) with or without data providers. For example, you can use a DataTable object with or without providers and shared or common components are the base classes for data providers. Shared or common components are the base classes for data providers and shared by all data providers. The data provider components are specifically designed to work with different kinds of data sources. For example, ODBC data providers work with ODBC data sources and OleDb data providers work with OLE-DB data sources.

Source: c-sharpcorner.com

Q10: What is exactly meaning of disconnected and connected approach in ADO.NET? ⭐⭐

Answer: In short:

  • Disconnected = Make Connection , Fetch Data , Close Connection
  • Connected = Make Connection , Keep Connection alive , Close Connection when close is called.

The ADO.net architecture, in which connection must be kept open till the end to retrieve and access data from database is called as connected architecture. Connected architecture is built on the these types - connection, command, datareader

The ADO.net architecture, in which connection will be kept open only till the data retrieved from database, and later can be accessed even when connection to database is closed is called as disconnected architecture. Disconnected architecture of ADO.net is built on these types - connection, dataadapter, commandbuilder and dataset and dataview.

Source: stackoverflow.com

Q11: Mention what is the difference between ADO.NET and classic ADO? ⭐⭐⭐

Answer:

  • In NET, we have data-set while ADO we have record-set
  • In record-set we can only have one table and to insert more than one table you have to do inner join. While the dataset in ADO.NET can have multiple tables
  • In NET, all data persist in XML while in classic ADO the data persists in binary format also

Source: career.guru99.com

Q12: Could you explain me some of the main differences between Connection-oriented access and connectionless access in ADO.NET? ⭐⭐⭐

Answer:

  • Connection Oriented means : connection is exist throw out your process. Example : using DataReader in Ado.Net you can get data as connection oriented database connection type.
  • Connection Less means : Your connection is not available throw out your whole process. Example: using DataAdapter in Ado.Net you can get data as connection less database connection type.

Source: stackoverflow.com

Q13: What is the difference between Integrated Security = True and Integrated Security = SSPI? ⭐⭐⭐

Answer: To connect to the database server is recommended to use Windows Authentication, commonly known as integrated security. To specify the Windows authentication, you can use any of the following two key-value pairs with the data provider. NET Framework for SQL Server:

Integrated Security = true;
Integrated Security = SSPI;

However, only the second works with the data provider .NET Framework OleDb. If you set Integrated Security = true for ConnectionString an exception is thrown.

Source: stackoverflow.com

Q14: What is Unit Of Work? ⭐⭐⭐

Answer: Unit of Work is referred to as a single transaction that involves multiple operations of insert/update/delete and so on kinds. To say it in simple words, it means that for a specific user action (say registration on a website), all the transactions like insert/update/delete and so on are done in one single transaction, rather than doing multiple database transactions.

Source: c-sharpcorner.com

Q15: How could you control connection pooling behavior? ⭐⭐⭐

Answer: You can manage connection pools using certain keywords in your connection string. The important ones include the following:

  • ConnectionTimeout -- this is used to specify the wait period (in seconds) when a new database connection is requested for. The default value is 15.
  • MinPoolSize -- this represents the minimum number of connections in the pool.
  • MaxPoolSize -- this represents the maximum number of connections in the pool. The default value is 100.
  • Pooling -- this controls if connection pooling is turned on or off and can have a value of true of false. When this is set to true, the requested connection is retrieved from the appropriate connection pool.

Source: infoworld.com

Q16: What are the differences between using SqlDataAdapter vs SqlDataReader for getting data from a DB? ⭐⭐⭐

Answer: SqlDataReader:

  • Holds the connection open until you are finished (don't forget to close it or use using).
  • Can typically only be iterated over once
  • Is not as useful for updating back to the database

On the other hand, it:

  • Only has one record in memory at a time rather than an entire result set (this can be huge)
  • Is about as fast as you can get for that one iteration
  • Allows you start processing results sooner (once the first record is available)

SqlDataAdapter/DataSet:

  • Lets you close the connection as soon it's done loading data, and may even close it for you automatically
  • All of the results are available in memory
  • You can iterate over it as many times as you need, or even look up a specific record by index
  • Has some built-in faculties for updating back to the database

At the cost of:

  • Much higher memory use
  • You wait until all the data is loaded before using any of it

So really it depends on what you're doing, but I tend to prefer a DataReader until I need something that's only supported by a dataset. SqlDataReader is perfect for the common data access case of binding to a read-only grid.

Source: stackoverflow.com

Q17: What is the difference between DataView, DataTable and DataSet? ⭐⭐⭐

Answer:

  • A DataTable is a collection of DataRows whose DataColumns satisfy a particular schema and may be subject to certain Constraints. As such, it is normally used as an 'in memory' representation of the rows, columns and constraints of a relational database table.
  • A DataSet is a collection of DataTables and DataRelations between them. As such, it can be used to represent all the tables within a relational database file and the parent/child relationships between them.
  • A DataView is a customized view of a DataTable for sorting, filtering, searching, editing, and navigation. It corresponds to a view (i.e. a virtual table produced by a query) in a relational database.

Source: c-sharpcorner.com

Q18: What is the difference between ExecuteScalar, ExecuteReader and ExecuteNonQuery? ⭐⭐⭐

Answer:

  • ExecuteScalar is typically used when your query returns a single value. If it returns more, then the result is the first column of the first row. An example might be SELECT @@IDENTITY AS 'Identity'.
  • ExecuteReader is used for any result set with multiple rows/columns (e.g., SELECT col1, col2 from sometable).
  • ExecuteNonQuery is typically used for SQL statements without results (e.g., UPDATE, INSERT, etc.).

Source: stackoverflow.com

Q19: What is the difference between OLE DB and ODBC data sources? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q20: What is the difference between ADODB, OLEDB and ADO.NET? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q21: How could you monitor connection pooling behavior? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q22: Can you explain the difference between a DataReader, a DataAdapter, a Dataset, and a DataView? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: Where should I use disconnected architecture approach? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: Where should I use connected architecture approach? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Is there anything faster than SqlDataReader in .NET? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: Is it necessary to manually close and dispose of SqlDataReader? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: What's better: DataSet or DataReader? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: Could you explain some benefits of Repository Pattern? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: Name types of transactions in ADO.NET ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Name some problems that could occur with connection pooling ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: What are the advantages of using Stored Procedures? ⭐⭐⭐

Answer:

  • Stored procedure can reduced network traffic and latency, boosting application performance.
  • Stored procedure execution plans can be reused, staying cached in SQL Server's memory, reducing server overhead.
  • Stored procedures help promote code reuse.
  • Stored procedures can encapsulate logic. You can change stored procedure code without affecting clients.
  • Stored procedures provide better security to your data.

Source: github.com/dhaval1406

Q32: What is Denormalization? ⭐⭐⭐

Answer: It is the process of improving the performance of the database by adding redundant data.

Source: github.com/dhaval1406

Q33: Define ACID Properties ⭐⭐⭐

Answer:

  • Atomicity: It ensures all-or-none rule for database modifications.
  • Consistency: Data values are consistent across the database.
  • Isolation: Two transactions are said to be independent of one another.
  • Durability: Data is not lost even at the time of server failure.

Source: github.com/chetansomani

Q34: How do I UPDATE from a SELECT in SQL Server? ⭐⭐⭐

Answer:

UPDATE
    Table_A
SET
    Table_A.col1 = Table_B.col1,
    Table_A.col2 = Table_B.col2
FROM
    Some_Table AS Table_A
    INNER JOIN Other_Table AS Table_B
        ON Table_A.id = Table_B.id
WHERE
    Table_A.col3 = 'cool'

or using MERGE:

MERGE INTO YourTable T
   USING other_table S 
      ON T.id = S.id
         AND S.tsql = 'cool'
WHEN MATCHED THEN
   UPDATE 
      SET col1 = S.col1, 
          col2 = S.col2;

Source: github.com/chetansomani

Q35: Discuss INNER JOIN ON vs WHERE clause ⭐⭐⭐

Details: You can do:

SELECT
    table1.this, table2.that, table2.somethingelse
FROM
    table1, table2
WHERE
    table1.foreignkey = table2.primarykey
    AND (some other conditions)

Or else:

SELECT
    table1.this, table2.that, table2.somethingelse
FROM
    table1 INNER JOIN table2
    ON table1.foreignkey = table2.primarykey
WHERE
    (some other conditions)

What syntax would you choose and why?

Answer: INNER JOIN is ANSI syntax which you should use. INNER JOIN helps human readability, and that's a top priority. It can also be easily replaced with an OUTER JOIN whenever a need arises.

Implicit joins (with multiple FROM tables) become much much more confusing, hard to read, and hard to maintain once you need to start adding more tables to your query.

Source: stackoverflow.com

Q36: How to generate row number in SQL Without ROWNUM ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q37: How does truncate and delete operation effect Identity? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q38: What is Optimistic Locking and Pessimistic locking? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q39: How does database indexing work? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q40: What are some other types of indexes? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 42 Advanced Java Interview Questions For Senior Developers | FullStack.Cafe

Q1: What is the difference between an Interface and an Abstract class? ⭐⭐

Answer: Java provides and supports the creation both of abstract classes and interfaces. Both implementations share some common characteristics, but they differ in the following features:

  • All methods in an interface are implicitly abstract. On the other hand, an abstract class may contain both abstract and non-abstract methods.
  • A class may implement a number of Interfaces, but can extend only one abstract class.
  • In order for a class to implement an interface, it must implement all its declared methods. However, a class may not implement all declared methods of an abstract class. Though, in this case, the sub-class must also be declared as abstract.
  • Abstract classes can implement interfaces without even providing the implementation of interface methods.
  • Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
  • Members of a Java interface are public by default. A member of an abstract class can either be private, protected or public.
  • An interface is absolutely abstract and cannot be instantiated. An abstract class also cannot be instantiated, but can be invoked if it contains a main method.

Source: github.com/snowdream

Q2: What differences exist between HashMap and Hashtable? ⭐⭐

Answer: There are several differences between HashMap and Hashtable in Java:

  1. Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.

  2. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values.

  3. One of HashMap's subclasses is LinkedHashMap, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the HashMap for a LinkedHashMap. This wouldn't be as easy if you were using Hashtable.

Source: stackoverflow.com

Q3: What is the difference between Exception and Error in java? ⭐⭐

Answer:

  • An Error "indicates serious problems that a reasonable application should not try to catch."
  • An Exception "indicates conditions that a reasonable application might want to catch."

Source: github.com/snowdream

Q4: How does Garbage Collection prevent a Java application from going out of memory? ⭐⭐

Answer: It doesn’t! Garbage Collection simply cleans up unused memory when an object goes out of scope and is no longer needed. However an application could create a huge number of large objects that causes an OutOfMemoryError.

Source: codementor.io

Q5: What is reflection and why is it useful? ⭐⭐

Answer: The name reflection is used to describe code which is able to inspect other code in the same system (or itself) and to make modifications at runtime.

For example, say you have an object of an unknown type in Java, and you would like to call a 'doSomething' method on it if one exists. Java's static typing system isn't really designed to support this unless the object conforms to a known interface, but using reflection, your code can look at the object and find out if it has a method called 'doSomething' and then call it if you want to.

Method method = foo.getClass().getMethod("doSomething", null);
method.invoke(foo, null);

Source: stackoverflow.com

Q6: What is Function Overriding and Overloading in Java? ⭐⭐

Answer:

  • Method overloading in Java occurs when two or more methods in the same class have the exact same name, but different parameters.
class Dog{
    public void bark(){
        System.out.println("woof ");
    }
 
    //overloading method
    public void bark(int num){
    	for(int i=0; i<num; i++)
    		System.out.println("woof ");
    }
}
  • On the other hand, method overriding is defined as the case when a child class redefines the same method as a parent class. Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides.
class Dog{
    public void bark(){
        System.out.println("woof ");
    }
}
class Hound extends Dog{
    public void sniff(){
        System.out.println("sniff ");
    }
 
    public void bark(){
        System.out.println("bowl");
    }
}
 
public class OverridingTest{
    public static void main(String [] args){
        Dog dog = new Hound();
        dog.bark();
    }
}

Source: github.com/snowdream

Q7: How can I synchornize two Java processes? ⭐⭐⭐

Answer: It is not possible to do something like you want in Java. Different Java applications will use different JVM's fully separating themselves into different 'blackbox'es. However, you have 2 options:

  • Use sockets (or channels). Basically one application will open the listening socket and start waiting until it receives some signal. The other application will connect there, and send signals when it had completed something. I'd say this is a preferred way used in 99.9% of applications.
  • You can call winapi from Java (on windows).

Source: stackoverflow.com

Q8: What is difference between fail-fast and fail-safe? ⭐⭐⭐

Answer: The Iterator's fail-safe property works with the clone of the underlying collection and thus, it is not affected by any modification in the collection. All the collection classes in java.util package are fail-fast, while the collection classes in java.util.concurrent are fail-safe. Fail-fast iterators throw a ConcurrentModificationException, while fail-safe iterator never throws such an exception.

Source: github.com/snowdream

Q9: What is the tradeoff between using an unordered array versus an ordered array? ⭐⭐⭐

Answer: The major advantage of an ordered array is that the search times have time complexity of O(log n), compared to that of an unordered array, which is O (n). The disadvantage of an ordered array is that the insertion operation has a time complexity of O(n), because the elements with higher values must be moved to make room for the new element. Instead, the insertion operation for an unordered array takes constant time of O(1).

Source: github.com/snowdream

Q10: What is structure of Java Heap? ⭐⭐⭐

Answer: The JVM has a heap that is the runtime data area from which memory for all class instances and arrays is allocated. It is created at the JVM start-up. Heap memory for objects is reclaimed by an automatic memory management system which is known as a garbage collector. Heap memory consists of live and dead objects. Live objects are accessible by the application and will not be a subject of garbage collection. Dead objects are those which will never be accessible by the application, but have not been collected by the garbage collector yet. Such objects occupy the heap memory space until they are eventually collected by the garbage collector.

Source: github.com/snowdream

Q11: What is the difference between throw and throws? ⭐⭐⭐

Answer: The throw keyword is used to explicitly raise a exception within the program. On the contrary, the throws clause is used to indicate those exceptions that are not handled by a method. Each method must explicitly specify which exceptions does not handle, so the callers of that method can guard against possible exceptions. Finally, multiple exceptions are separated by a comma.

Source: github.com/snowdream

Q12: Is Java “pass-by-reference” or “pass-by-value”? ⭐⭐⭐

Answer: Java is always pass-by-value. Unfortunately, when we pass the value of an object, we are passing the reference to it. There is no such thing as "pass-by-reference" in Java. This is confusing to beginners.

The key to understanding this is that something like

Dog myDog;

is not a Dog; it's actually a pointer to a Dog.

So when you have

Dog myDog = new Dog("Rover");
foo(myDog);

you're essentially passing the address of the created Dog object to the foo method.

Source: stackoverflow.com

Q13: What is a JavaBean exactly? ⭐⭐⭐

Answer: Basically, a "Bean" follows the standart:

  • is a serializable object (that is, it implements java.io.Serializable, and does so correctly), that
  • has "properties" whose getters and setters are just methods with certain names (like, say, getFoo() is the getter for the "Foo" property), and
  • has a public 0-arg constructor (so it can be created at will and configured by setting its properties).

There is no syntactic difference between a JavaBean and another class - a class is a JavaBean if it follows the standards.

Source: stackoverflow.com

Q14: Can == be used on enum? ⭐⭐⭐

Answer: Yes: enums have tight instance controls that allows you to use == to compare instances. Here's the guarantee provided by the language specification.

Source: stackoverflow.com

Q15: What are the differences between == and equals? ⭐⭐⭐

Answer: As a reminder, it needs to be said that generally, == is NOT a viable alternative to equals. When it is, however (such as with enum), there are two important differences to consider:

  1. == never throws NullPointerException
enum Color { BLACK, WHITE };

Color nothing = null;
if (nothing == Color.BLACK);      // runs fine
if (nothing.equals(Color.BLACK)); // throws NullPointerEx
  1. == is subject to type compatibility check at compile time
enum Color { BLACK, WHITE };
enum Chiral { LEFT, RIGHT };

if (Color.BLACK.equals(Chiral.LEFT)); // compiles fine
if (Color.BLACK == Chiral.LEFT);      // DOESN'T COMPILE!!! Incompatible types!

Source: stackoverflow.com

Q16: What is the main difference between StringBuffer and StringBuilder? ⭐⭐⭐

Answer:

  • StringBuffer is synchronized, StringBuilder is not. When some thing is synchronized, then multiple threads can access, and modify it with out any problem or side effect. StringBuffer is synchronized, so you can use it with multiple threads with out any problem.

  • StringBuilder is faster than StringBuffer because it's not synchronized. Using synchronized methods in a single thread is overkill.

Source: stackoverflow.com

Q17: Why does Java have transient fields? ⭐⭐⭐

Answer: The transient keyword in Java is used to indicate that a field should not be part of the serialization.

By default, all of object's variables get converted into a persistent state. In some cases, you may want to avoid persisting some variables because you don't have the need to persist those variables. So you can declare those variables as transient. If the variable is declared as transient, then it will not be persisted.

Source: stackoverflow.com

Q18: What is static initializer? ⭐⭐⭐

Details:

Answer: The static initializer is a static {} block of code inside java class, and run only one time before the constructor or main method is called. If you had to perform a complicated calculation to determine the value of x — or if its value comes from a database — a static initializer could be very useful.

Consider:

class StaticInit {
    public static int x;
    static {
        x = 32;
    }
    // other class members such as constructors and
    // methods go here...
}

Source: stackoverflow.com

Q19: Is there anything like static class in java? ⭐⭐⭐

Answer: Java has no way of making a top-level class static but you can simulate a static class like this:

  • Declare your class final - Prevents extension of the class since extending a static class makes no sense
  • Make the constructor private - Prevents instantiation by client code as it makes no sense to instantiate a static class
  • Make all the members and functions of the class static - Since the class cannot be instantiated no instance methods can be called or instance fields accessed
  • Note that the compiler will not prevent you from declaring an instance (non-static) member. The issue will only show up if you attempt to call the instance member

Source: stackoverflow.com

Q20: What do the ... dots in the method parameters mean? ⭐⭐⭐

Details: What do the 3 dots in the following method mean?

public void myMethod(String... strings){
    // method body
}

Answer: That feature is called varargs, and it's a feature introduced in Java 5. It means that function can receive multiple String arguments:

myMethod("foo", "bar");
myMethod("foo", "bar", "baz");
myMethod(new String[]{"foo", "var", "baz"}); // you can eve

Then, you can use the String var as an array:

public void myMethod(String... strings){
    for(String whatever : strings){
        // do what ever you want
    }

    // the code above is is equivalent to
    for( int i = 0; i < strings.length; i++){
        // classical for. In this case you use strings[i]
    }
}

Source: stackoverflow.com

Q21: What is the JIT? ⭐⭐⭐

Answer: The JIT is the JVM’s mechanism by which it can optimize code at runtime.

JIT means Just In Time. It is a central feature of any JVM. Among other optimizations, it can perform code inlining, lock coarsening or lock eliding, escape analysis etc.

The main benefit of the JIT is on the programmer’s side: code should be written so that it just works; if the code can be optimized at runtime, more often than not, the JIT will find a way.

Source: codementor.io

Q22: What is the difference between a synchronized method and a synchronized block? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q23: What is the difference between Serial and Throughput Garbage collector? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: Given two double values d1, d2, what is the most reliable way to test their equality? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q25: Explain Marshalling and demarshalling. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q26: Why is char[] preferred over String for passwords? ⭐⭐⭐⭐

Details: Why does String pose a threat to security when it comes to passwords? It feels inconvenient to use char[]?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q27: When to use LinkedList over ArrayList in Java? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q28: What is Double Brace initialization in Java? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: Is it possible to call one constructor from another in Java? ⭐⭐⭐⭐

Details: Is it possible to call a constructor from another (within the same class, not from a subclass)? If yes how?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Does Java support default parameter values? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: Explain a use case for the Builder Design Pattern ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: Is null check needed before calling instanceof? ⭐⭐⭐⭐

Details: Will

null instanceof SomeClass

return false or throw a NullPointerException?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: What exactly is marker interface in Java? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q34: What does 'synchronized' mean? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q35: Why ArrayList are preferable in many more use-cases than LinkedList? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q36: What's wrong with Double Brace initialization in Java? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q37: Provide some examples when a finally block won't be executed in Java? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q38: Explain what will the code return ⭐⭐⭐⭐⭐

Details: Consider:

try { return true; } finally { return false; }

Answer: Read Full Answer on 👉 FullStack.Cafe

Q39: What is an efficient way to implement a singleton pattern in Java? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q40: What's the difference between SoftReference and WeakReference in Java? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q41: Why isn’t String‘s .length() accurate? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q42: Compare volatile vs static variables in Java ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 45 Important PHP Interview Questions That May Land You a Job | FullStack.Cafe

Q1: What is the difference between == and ===? ⭐

Answer:

  • The operator == casts between two different types if they are different
  • The === operator performs a 'typesafe comparison'

That means that it will only return true if both operands have the same type and the same value.

1 === 1: true
1 == 1: true
1 === "1": false // 1 is an integer, "1" is a string
1 == "1": true // "1" gets casted to an integer, which is 1
"foo" === "foo": true // both operands are strings and have the same value

Source: stackoverflow.com

Q2: How can you pass a variable by reference? ⭐

Answer: To be able to pass a variable by reference, we use an ampersand in front of it, as follows:

$var1 = &$var2

Source: guru99.com

Q3: What does $GLOBALS mean? ⭐

Answer: $GLOBALS is associative array including references to all variables which are currently defined in the global scope of the script.

Source: guru99.com

Q4: What is the use of ini_set()? ⭐

Answer: PHP allows the user to modify some of its settings mentioned in php.ini using ini_set(). This function requires two string arguments. First one is the name of the setting to be modified and the second one is the new value to be assigned to it.

Given line of code will enable the display_error setting for the script if it’s disabled.

ini_set('display_errors', '1');

We need to put the above statement, at the top of the script so that, the setting remains enabled till the end. Also, the values set via ini_set() are applicable, only to the current script. Thereafter, PHP will start using the original values from php.ini.

Source: github.com/Bootsity

Q5: When should I use require vs. include? ⭐⭐

Answer: The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.

My suggestion is to just use require_once 99.9% of the time.

Using require or include instead implies that your code is not reusable elsewhere, i.e. that the scripts you're pulling in actually execute code instead of making available a class or some function libraries.

Source: stackoverflow.com

Q6: What is stdClass in PHP? ⭐⭐

Answer: stdClass is just a generic 'empty' class that's used when casting other types to objects. stdClass is not the base class for objects in PHP. This can be demonstrated fairly easily:

class Foo{}
$foo = new Foo();
echo ($foo instanceof stdClass)?'Y':'N'; // outputs 'N'

It is useful for anonymous objects, dynamic properties, etc.

An easy way to consider the StdClass is as an alternative to associative array. See this example below that shows how json_decode() allows to get an StdClass instance or an associative array. Also but not shown in this example, SoapClient::__soapCall returns an StdClass instance.

//Example with StdClass
$json = '{ "foo": "bar", "number": 42 }';
$stdInstance = json_decode($json);

echo $stdInstance - > foo.PHP_EOL; //"bar"
echo $stdInstance - > number.PHP_EOL; //42

//Example with associative array
$array = json_decode($json, true);

echo $array['foo'].PHP_EOL; //"bar"
echo $array['number'].PHP_EOL; //42

Source: stackoverflow.com

Q7: What are the differences between die() and exit() functions in PHP? ⭐⭐

Answer: There's no difference - they are the same. The only advantage of choosing die() over exit(), might be the time you spare on typing an extra letter.

Source: stackoverflow.com

Q8: What are the main differences between const vs define ⭐⭐

Answer: The fundamental difference between const vs define is that const defines constants at compile time, whereas define defines them at run time.

const FOO = 'BAR';
define('FOO', 'BAR');

// but
if (...) {
    const FOO = 'BAR';    // Invalid
}
if (...) {
    define('FOO', 'BAR'); // Valid
}

Also until PHP 5.3, const could not be used in the global scope. You could only use this from within a class. This should be used when you want to set some kind of constant option or setting that pertains to that class. Or maybe you want to create some kind of enum. An example of good const usage is to get rid of magic numbers.

Define can be used for the same purpose, but it can only be used in the global scope. It should only be used for global settings that affect the entire application.

Unless you need any type of conditional or expressional definition, use consts instead of define() - simply for the sake of readability!

Source: stackoverflow.com

Q9: What's the difference between isset() and array_key_exists()? ⭐⭐

Answer:

  • array_key_exists will tell you if a key exists in an array and complains when $a does not exist.
  • isset will only return true if the key/variable exists and is not null. isset doesn't complain when $a does not exist.

Consider:

$a = array('key1' => 'Foo Bar', 'key2' => null);

isset($a['key1']);             // true
array_key_exists('key1', $a);  // true

isset($a['key2']);             // false
array_key_exists('key2', $a);  // true

Source: stackoverflow.com

Q10: What is the difference between var_dump() and print_r()? ⭐⭐

Answer:

  • The var_dump function displays structured information about variables/expressions including its type and value. Arrays are explored recursively with values indented to show structure. It also shows which array values and object properties are references.

  • The print_r() displays information about a variable in a way that's readable by humans. array values will be presented in a format that shows keys and elements. Similar notation is used for objects.

Consider:

$obj = (object) array('qualitypoint', 'technologies', 'India');

var_dump($obj) will display below output in the screen:

object(stdClass)#1 (3) {
 [0]=> string(12) "qualitypoint"
 [1]=> string(12) "technologies"
 [2]=> string(5) "India"
}

And, print_r($obj) will display below output in the screen.

stdClass Object ( 
 [0] => qualitypoint
 [1] => technologies
 [2] => India
)

Source: stackoverflow.com

Q11: Explain what the different PHP errors are ⭐⭐

Answer:

  • A notice is a non-critical error saying something went wrong in execution, something minor like an undefined variable.
  • A warning is given when a more critical error like if an include() command went to retrieve a non-existent file. In both this and the error above, the script would continue.
  • A fatal error would terminate the code. Failure to satisfy a require() would generate this type of error, for example.

Source: pangara.com

Q12: How can you enable error reporting in PHP? ⭐⭐

Answer: Check if “display_errors” is equal “on” in the php.ini or declare “ini_set('display_errors', 1)” in your script.

Then, include “error_reporting(E_ALL)” in your code to display all types of error messages during the script execution.

Source: codementor.io

Q13: Declare some function with default parameter ⭐⭐

Answer: Consider:

function showMessage($hello = false){
  echo ($hello) ? 'hello' : 'bye';
}

Source: codementor.io

Q14: Is multiple inheritance supported in PHP? ⭐⭐

Answer: PHP supports only single inheritance; it means that a class can be extended from only one single class using the keyword 'extended'.

Source: guru99.com

Q15: In PHP, objects are they passed by value or by reference? ⭐⭐

Answer: In PHP, objects passed by value.

Source: guru99.com

Q16: What is the differences between $a != $b and $a !== $b? ⭐⭐

Answer: != means inequality (TRUE if $a is not equal to $b) and !== means non-identity (TRUE if $a is not identical to $b).

Source: guru99.com

Q17: What is PDO in PHP? ⭐⭐

Answer: PDO stands for PHP Data Object.

It is a set of PHP extensions that provide a core PDO class and database, specific drivers. It provides a vendor-neutral, lightweight, data-access abstraction layer. Thus, no matter what database we use, the function to issue queries and fetch data will be same. It focuses on data access abstraction rather than database abstraction.

Source: github.com/Bootsity

Q18: Explain how we handle exceptions in PHP? ⭐⭐

Answer: When an exception is thrown, code following the statement will not be executed, and PHP will attempt to find the first matching catch block. If an exception is not caught, a PHP Fatal Error will be issued with an "Uncaught Exception". An exception can be thrown, and caught within PHP.

To handle exceptions, code may be surrounded in a try block. Each try must have at least one corresponding catch block. Multiple catch blocks can be used to catch different classes of exceptions. Exceptions can be thrown (or re-thrown) within a catch block.

Consider:

try {
    print "this is our try block n";
    throw new Exception();
} catch (Exception $e) {
    print "something went wrong, caught yah! n";
} finally {
    print "this part is always executed n";
}

Source: github.com/Bootsity

Q19: Differentiate between echo and print() ⭐⭐

Answer: echo and print are more or less the same. They are both used to output data to the screen.

The differences are:

  • echo has no return value while print has a return value of 1 so it can be used in expressions.
  • echo can take multiple parameters (although such usage is rare) while print can take one argument.
  • echo is faster than print.

Source: github.com/Bootsity

Q20: When should I use require_once vs. require? ⭐⭐⭐

Answer: The require_once() statement is identical to require() except PHP will check if the file has already been included, and if so, not include (require) it again.

My suggestion is to just use require_once 99.9% of the time.

Using require or include instead implies that your code is not reusable elsewhere, i.e. that the scripts you're pulling in actually execute code instead of making available a class or some function libraries.

Source: stackoverflow.com

Q21: Check if PHP array is associative ⭐⭐⭐

Answer: Consider:

function has_string_keys(array $array) {
  return count(array_filter(array_keys($array), 'is_string')) > 0;
}

If there is at least one string key, $array will be regarded as an associative array.

Source: stackoverflow.com

Q22: How do I pass variables and data from PHP to JavaScript? ⭐⭐⭐

Answer: There are actually several approaches to do this:

  • Use AJAX to get the data you need from the server.
    Consider get-data.php:
echo json_encode(42);

Consider index.html:

<script>
    function reqListener () {
      console.log(this.responseText);
    }

    var oReq = new XMLHttpRequest(); // New request object
    oReq.onload = function() {
        // This is where you handle what to do with the response.
        // The actual data is found on this.responseText
        alert(this.responseText); // Will alert: 42
    };
    oReq.open("get", "get-data.php", true);
    //                               ^ Don't block the rest of the execution.
    //                                 Don't wait until the request finishes to
    //                                 continue.
    oReq.send();
</script>
  • Echo the data into the page somewhere, and use JavaScript to get the information from the DOM.
<div id="dom-target" style="display: none;">
    <?php
        $output = "42"; // Again, do some operation, get the output.
        echo htmlspecialchars($output); /* You have to escape because the result
                                           will not be valid HTML otherwise. */
    ?>
</div>
<script>
    var div = document.getElementById("dom-target");
    var myData = div.textContent;
</script>
  • Echo the data directly to JavaScript.
<script>
    var data = <?php echo json_encode("42", JSON_HEX_TAG); ?>; // Don't forget the extra semicolon!
</script>

Source: stackoverflow.com

Q23: Is there a function to make a copy of a PHP array to another? ⭐⭐⭐

Answer: In PHP arrays are assigned by copy, while objects are assigned by reference so PHP will copy the array by default. References in PHP have to be explicit:

$a = array(1,2);
$b = $a; // $b will be a different array
$c = &$a; // $c will be a reference to $a

Source: stackoverflow.com

Q24: What will be returned by this code? ⭐⭐⭐

Details: Consider the code:

$a = new stdClass();
$a->foo = "bar";
$b = clone $a;
var_dump($a === $b);

What will be echoed to the console?

Answer: Two instances of the same class with equivalent members do NOT match the === operator. So the answer is:

bool(false)

Source: stackoverflow.com

Q25: What will be returned by this code? Explain the result. ⭐⭐⭐

Details: Consider the code. What will be returned as a result?

$something = 0;
echo ('password123' == $something) ? 'true' : 'false';

Answer: The answer is true. You should never use == for string comparison. Even if you are comparing strings to strings, PHP will implicitly cast them to floats and do a numerical comparison if they appear numerical. === is OK.

For example

'1e3' == '1000' // true

also returns true.

Source: stackoverflow.com

Q26: What exactly is the the difference between array_map, array_walk and array_filter? ⭐⭐⭐

Answer:

  • array_walk takes an array and a function F and modifies it by replacing every element x with F(x).
  • array_map does the exact same thing except that instead of modifying in-place it will return a new array with the transformed elements.
  • array_filter with function F, instead of transforming the elements, will remove any elements for which F(x) is not true

Source: stackoverflow.com

Q27: Explain the difference between exec() vs system() vs passthru()? ⭐⭐⭐

Answer:

  • exec() is for calling a system command, and perhaps dealing with the output yourself.
  • system() is for executing a system command and immediately displaying the output - presumably text.
  • passthru() is for executing a system command which you wish the raw return from - presumably something binary.

Source: stackoverflow.com

Q28: How would you create a Singleton class using PHP? ⭐⭐⭐

Answer:

/**
 * Singleton class
 *
 */
final class UserFactory {
    /**
     * Call this method to get singleton
     *
     * @return UserFactory
     */
    public static
    function Instance() {
        static $inst = null;
        if ($inst === null) {
            $inst = new UserFactory();
        }
        return $inst;
    }

    /**
     * Private ctor so nobody else can instantiate it
     *
     */
    private
    function __construct() {

    }
}

To use:

$fact = UserFactory::Instance();
$fact2 = UserFactory::Instance();

But:

$fact = new UserFactory()

Throws an error.

Source: stackoverflow.com

Q29: What is the difference between PDO's query() vs execute()? ⭐⭐⭐

Answer:

  • query runs a standard SQL statement and requires you to properly escape all data to avoid SQL Injections and other issues.
  • execute runs a prepared statement which allows you to bind parameters to avoid the need to escape or quote the parameters. execute will also perform better if you are repeating a query multiple times.

Best practice is to stick with prepared statements and execute for increased security. Aside from the escaping on the client-side that it provides, a prepared statement is compiled on the server-side once, and then can be passed different parameters at each execution.

Source: stackoverflow.com

Q30: What is use of Null Coalesce Operator? ⭐⭐⭐

Answer: Null coalescing operator returns its first operand if it exists and is not NULL. Otherwise it returns its second operand.

Example:

$name = $firstName ?? $username ?? $placeholder ?? "Guest"; 

Source: github.com/Bootsity

Q31: Differentiate between exception and error ⭐⭐⭐

Answer:

  • Recovering from Error is not possible. The only solution to errors is to terminate the execution. Where as you can recover from Exception by using either try-catch blocks or throwing exception back to caller.
  • You will not be able to handle the Errors using try-catch blocks. Even if you handle them using try-catch blocks, your application will not recover if they happen. On the other hand, Exceptions can be handled using try-catch blocks and can make program flow normal if they happen.
  • Exceptions are related to application where as Errors are related to environment in which application is running.

Source: github.com/Bootsity

Q32: What are the exception class functions? ⭐⭐⭐

Answer: There are following functions which can be used from Exception class.

  • getMessage() − message of exception
  • getCode() − code of exception
  • getFile() − source filename
  • getLine() − source line
  • getTrace() − n array of the backtrace()
  • getTraceAsString() − formated string of trace
  • Exception::__toString gives the string representation of the exception.

Source: github.com/Bootsity

Q33: Differentiate between parameterised and non parameterised functions ⭐⭐⭐

Answer:

  • Non parameterised functions don't take any parameter at the time of calling.
  • Parameterised functions take one or more arguments while calling. These are used at run time of the program when output depends on dynamic values given at run time There are two ways to access the parameterised function:
  1. call by value: (here we pass the value directly )
  2. call by reference: (here we pass the address location where the value is stored)

Source: github.com/Bootsity

Q34: Explain function call by reference ⭐⭐⭐

Answer: In case of call by reference, actual value is modified if it is modified inside the function. In such case, we need to use & symbol with formal arguments. The & represents reference of the variable.

Example:

function adder(&$str2) {  
    $str2 .= 'Call By Reference';  
}
$str = 'This is ';  
adder($str);  
echo $str;  

Output:

This is Call By Reference

Source: github.com/Bootsity

Q35: Why do we use extract()? ⭐⭐⭐

Answer: The extract() function imports variables into the local symbol table from an array. This function uses array keys as variable names and values as variable values. For each element it will create a variable in the current symbol table. This function returns the number of variables extracted on success.

Example:

$a = "Original";
$my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse");
extract($my_array);
echo "\$a = $a; \$b = $b; \$c = $c";

Output:

$a = Cat; $b = Dog; $c = Horse

Source: github.com/Bootsity

Q36: explain what is a closure in PHP and why does it use the “use” identifier? ⭐⭐⭐⭐

Details: Consider this code:

public function getTotal($tax)
{
    $total = 0.00;

    $callback =
        function ($quantity, $product) use ($tax, &$total)
        {
            $pricePerItem = constant(__CLASS__ . "::PRICE_" .
                strtoupper($product));
            $total += ($pricePerItem * $quantity) * ($tax + 1.0);
        };

    array_walk($this->products, $callback);
    return round($total, 2);
}

Could you explain why use it?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q37: What exactly are late static bindings in PHP? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q38: How to measure execution times of PHP scripts? ⭐⭐⭐⭐

Details: I want to know how many milliseconds a PHP while-loop takes to execute. Could you help me?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q39: What is the best method to merge two PHP objects? ⭐⭐⭐⭐

Details:

//We have this:
$objectA->a;
$objectA->b;
$objectB->c;
$objectB->d;

//We want the easiest way to get:
$objectC->a;
$objectC->b;
$objectC->c;
$objectC->d;

Answer: Read Full Answer on 👉 FullStack.Cafe

Q40: Compare mysqli or PDO - what are the pros and cons? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q41: What is use of Spaceship Operator? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q42: Does PHP have threading? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q43: Is PHP single or multi threaded? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q44: Provide some ways to mimic multiple constructors in PHP ⭐⭐⭐⭐⭐

Details: It's known you can't put two __construct functions with unique argument signatures in a PHP class but I'd like to do something like this:

class Student 
{
   protected $id;
   protected $name;
   // etc.

   public function __construct($id){
       $this->id = $id;
      // other members are still uninitialised
   }

   public function __construct($row_from_database){
       $this->id = $row_from_database->id;
       $this->name = $row_from_database->name;
       // etc.
   }
}

What is the best way to achieve this in PHP?

Answer: Read Full Answer on 👉 FullStack.Cafe

Q45: How could we implement method overloading in PHP? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 5 Salary Negotiation Rules for Software Developers | FullStack.Cafe

Q1: career test ⭐⭐⭐

Details: test

Answer: test

Originally published on 👉 50 Common Front End Developer Interview Questions [2019 Edition] | FullStack.Cafe

Q1: Explain the CSS “box model” and the layout components that it consists of ⭐⭐

Answer: The CSS box model is a rectangular layout paradigm for HTML elements that consists of the following:

  • Content - The content of the box, where text and images appear
  • Padding - A transparent area surrounding the content (i.e., the amount of space between the border and the content)
  • Border - A border surrounding the padding (if any) and content
  • Margin - A transparent area surrounding the border (i.e., the amount of space between the border and any neighboring elements)

Source: toptal.com

Q2: What is a CSS rule? ⭐⭐

Answer: Web browsers apply CSS rules to a document to affect how they are displayed. A CSS rule is formed from:

  • A set of properties, which have values set to update how the HTML content is displayed,
  • A selector, which selects the element(s) you want to apply the updated property values to.

A set of CSS rules contained within a stylesheet determines how a webpage should look.

Source: developer.mozilla.org

Q3: What is Sass? ⭐⭐

Answer: Sass or Syntactically Awesome StyleSheets is a CSS preprocessor that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly.

A CSS preprocessor is a scripting language that extends CSS by allowing developers to write code in one language and then compile it into CSS.

Source: sass-lang.com

Q4: What is a Mixin and how to use on? ⭐⭐⭐

Answer: A Mixin is a block of code that lets us group CSS declarations we may reuse throughout our site.

To define mixin:

@mixin grid($flex: true /*default argument*/) {
    @if $flex {
        @include flex;
    } @else {
        display: block;
    }
}

To use a Mixin, we simply use @include followed by the name of the Mixin and a semi-colon.

/*scss*/
.row {
    @include grid(true);
}

/*css*/
.row {
    display: -webkit-flex;
    display: flex;
}

Source: scotch.io

Q5: What’s the difference between “resetting” and “normalizing” CSS? Which would you choose, and why? ⭐⭐⭐

Answer:

  • Resetting — is meant to strip all default browser styling on elements. For e.g. margins, paddings, font-sizes of all elements are reset to be the same. You will have to redeclare styling for common typographic elements.
  • Normalizing — preserves useful default styles rather than “unstyling” everything. It also corrects bugs for common browser dependencies.

It's a good idea to choose resetting when you have very a customized or unconventional site design such that I need to do a lot of my own styling do not need any default styling to be preserved.

Source: codeburst.io

Q6: What is a Grid System in CSS? ⭐⭐⭐

Answer: A grid system is a structure that allows for content to be stacked both vertically and horizontally in a consistent and easily manageable fashion. Grid systems include two key components: rows and columns.

Some Grid Systems:

  • Simple Grid
  • Pure
  • Flexbox Grid
  • Bootstrap
  • Foundation

Source: sitepoint.com

Q7: Explain meta tags in HTML ⭐

Answer:

  • Meta tags always go inside head tag of the HTML page
  • Meta tags is always passed as name/value pairs
  • Meta tags are not displayed on the page but intended for the browser
  • Meta tags can contain information about character encoding, description, title of the document etc,

Example:

<!DOCTYPE html>
<html>
<head>
  <meta name="description" content="I am a web page with description"> 
  <title>Home Page</title>
</head>
<body>
  
</body>
</html>

Source: github.com/FuelFrontend

Q8: What is the difference between span and div? ⭐⭐

Answer:

  • div is a block element
  • span is inline element

For bonus points, you could point out that it’s illegal to place a block element inside an inline element, and that while div can have a p tag, and a p tag can have a span, it is not possible for span to have a div or p tag inside.

Source: thatjsdude.com

Q9: What are defer and async attributes on a <script> tag? ⭐⭐⭐

Answer: If neither attribute is present, the script is downloaded and executed synchronously, and will halt parsing of the document until it has finished executing (default behavior). Scripts are downloaded and executed in the order they are encountered.

The defer attribute downloads the script while the document is still parsing but waits until the document has finished parsing before executing it, equivalent to executing inside a DOMContentLoaded event listener. defer scripts will execute in order.

The async attribute downloads the script during parsing the document but will pause the parser to execute the script before it has fully finished parsing. async scripts will not necessarily execute in order.

Note: both attributes must only be used if the script has a src attribute (i.e. not an inline script).

<script src="myscript.js"></script>
<script src="myscript.js" defer></script>
<script src="myscript.js" async></script>

Source: growingwiththeweb.com

Q10: What's new in HTML 5? ⭐⭐⭐

Answer: HTML 5 adds a lot of new features to the HTML specification

New Doctype

Still using that pesky, impossible-to-memorize XHTML doctype?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If so, why? Switch to the new HTML5 doctype. You'll live longer -- as Douglas Quaid might say.

<!DOCTYPE html>

New Structure

  • <section> - to define sections of pages
  • <header> - defines the header of a page
  • <footer> - defines the footer of a page
  • <nav> - defines the navigation on a page
  • <article> - defines the article or primary content on a page
  • <aside> - defines extra content like a sidebar on a page
  • <figure> - defines images that annotate an article

New Inline Elements

These inline elements define some basic concepts and keep them semantically marked up, mostly to do with time:

  • <mark> - to indicate content that is marked in some fashion
  • <time> - to indicate content that is a time or date
  • <meter> - to indicate content that is a fraction of a known range - such as disk usage
  • <progress> - to indicate the progress of a task towards completion

New Form Types

  • <input type="datetime">
  • <input type="datetime-local">
  • <input type="date">
  • <input type="month">
  • <input type="week">
  • <input type="time">
  • <input type="number">
  • <input type="range">
  • <input type="email">
  • <input type="url">

New Elements

There are a few exciting new elements in HTML 5:

  • <canvas> - an element to give you a drawing space in JavaScript on your Web pages. It can let you add images or graphs to tool tips or just create dynamic graphs on your Web pages, built on the fly.
  • <video> - add video to your Web pages with this simple tag.
  • <audio> - add sound to your Web pages with this simple tag.

No More Types for Scripts and Links

You possibly still add the type attribute to your link and script tags.

<link rel="stylesheet" href="path/to/stylesheet.css" type="text/css" />
<script type="text/javascript" src="path/to/script.js"></script>

This is no longer necessary. It's implied that both of these tags refer to stylesheets and scripts, respectively. As such, we can remove the type attribute all together.

<link rel="stylesheet" href="path/to/stylesheet.css" />
<script src="path/to/script.js"></script>

Make your content editable

The new browsers have a nifty new attribute that can be applied to elements, called contenteditable. As the name implies, this allows the user to edit any of the text contained within the element, including its children. There are a variety of uses for something like this, including an app as simple as a to-do list, which also takes advantage of local storage.

<h2> To-Do List </h2>
<ul contenteditable="true">
  <li> Break mechanical cab driver. </li>
  <li> Drive to abandoned factory
  <li> Watch video of self </li>
</ul>

Attributes

  • require to mention the form field is required
  • autofocus puts the cursor on the input field

Source: github.com/FuelFrontend

Q11: What is Coercion in JavaScript?

Answer: In JavaScript conversion between different two build-in types called coercion. Coercion comes in two forms in JavaScript: explicit and implicit.

Here's an example of explicit coercion:

var a = "42";

var b = Number( a );

a;				// "42"
b;				// 42 -- the number!

And here's an example of implicit coercion:

var a = "42";

var b = a * 1;	// "42" implicitly coerced to 42 here

a;				// "42"
b;				// 42 -- the number!

Q12: What is Scope in JavaScript? ⭐

Answer: In JavaScript, each function gets its own scope. Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function's scoped variables.

A variable name has to be unique within the same scope. A scope can be nested inside another scope. If one scope is nested inside another, code inside the innermost scope can access variables from either scope.

Q13: What is strict mode? ⭐⭐

Answer: Strict Mode is a new feature in ECMAScript 5 that allows you to place a program, or a function, in a "strict" operating context. This strict context prevents certain actions from being taken and throws more exceptions.

// Non-strict code...

(function(){
  "use strict";

  // Define your library strictly...
})();

// Non-strict code...

Q14: What is IIFEs (Immediately Invoked Function Expressions)? ⭐⭐⭐

Answer: It’s an Immediately-Invoked Function Expression, or IIFE for short. It executes immediately after it’s created:

(function IIFE(){
	console.log( "Hello!" );
})();
// "Hello!"

This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.

Source: stackoverflow.com

Q15: What is “closure” in javascript? Provide an example? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: Explain the Prototype Design Pattern ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q17: Compare SQL databases and MongoDB at a high level. ⭐⭐

Answer: SQL databases store data in form of tables, rows, columns and records. This data is stored in a pre-defined data model which is not very much flexible for today's real-world highly growing applications. MongoDB in contrast uses a flexible structure which can be easily modified and extended.

Source: tutorialspoint.com

Q18: What is Node.js? ⭐

Answer: Node.js is a web application framework built on Google Chrome's JavaScript Engine (V8 Engine).

Node.js comes with runtime environment on which a Javascript based script can be interpreted and executed (It is analogus to JVM to JAVA byte code). This runtime allows to execute a JavaScript code on any machine outside a browser. Because of this runtime of Node.js, JavaScript is now can be executed on server as well.

Node.js = Runtime Environment + JavaScript Library

Source: tutorialspoint.com

Q19: What is npm? ⭐

Answer: npm stands for Node Package Manager. npm provides following two main functionalities:

  • Online repositories for node.js packages/modules which are searchable on search.nodejs.org
  • Command line utility to install packages, do version management and dependency management of Node.js packages.

Source: tutorialspoint.com

Q20: If Node.js is single threaded then how it handles concurrency? ⭐⭐

Answer: Node provides a single thread to programmers so that code can be written easily and without bottleneck. Node internally uses multiple POSIX threads for various I/O operations such as File, DNS, Network calls etc.

When Node gets I/O request it creates or uses a thread to perform that I/O operation and once the operation is done, it pushes the result to the event queue. On each such event, event loop runs and checks the queue and if the execution stack of Node is empty then it adds the queue result to execution stack.

This is how Node manages concurrency.

Source: codeforgeek.com

Q21: What is Callback Hell? ⭐⭐

Answer: The asynchronous function requires callbacks as a return parameter. When multiple asynchronous functions are chained together then callback hell situation comes up.

Source: codeforgeek.com

Q22: How can you avoid callback hells? ⭐⭐⭐

Answer: To do so you have more options:

  • modularization: break callbacks into independent functions
  • use Promises
  • use yield with Generators and/or Promises

Source: tutorialspoint.com

Q23: How would you scale Node application? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q24: What is encapsulation? ⭐⭐

Answer: Encapsulation is defined as the process of enclosing one or more items within a physical or logical package. Encapsulation, in object oriented programming methodology, prevents access to implementation details.

Source: tutorialspoint.com

Q25: What is polymorphism? ⭐⭐

Answer: The word polymorphism means having many forms. In object-oriented programming paradigm, polymorphism is often expressed as one interface, multiple functions.

Source: tutorialspoint.com

Q26: What is ReactJS? ⭐

Answer: ReactJS is an open-source frontend JavaScript library which is used for building user interfaces especifically for single page applications. It is used for handling view layer for web and mobile apps. React was created by Jordan Walke, a software engineer working for Facebook. ReactJS was first deployed on Facebook’s newsfeed in 2011 and on Instagram.com in 2012.

Source: https://github.com/sudheerj

Q27: What is the point of Redux? ⭐⭐

Answer: Application state management that is easy to reason about, maintain and manage in an asynchronous web application environment.

Source: github.com/WebPredict

Q28: What is Flux? ⭐⭐

Answer: Unidrectional application flow paradigm popular a few years back in React; mostly superceded by Redux these days.

Source: github.com/WebPredict

Q29: What are advantages of REST web services? ⭐⭐

Answer: Some of the advantages of REST web services are:

  • Learning curve is easy since it works on HTTP protocol
  • Supports multiple technologies for data transfer such as text, xml, json, image etc.
  • No contract defined between server and client, so loosely coupled implementation.
  • REST is a lightweight protocol
  • REST methods can be tested easily over browser.

Source: journaldev.com

Q30: Mention what is the difference between PUT and POST? ⭐⭐⭐

Answer: PUT puts a file or resource at a particular URI and exactly at that URI. If there is already a file or resource at that URI, PUT changes that file or resource. If there is no resource or file there, PUT makes one

POST sends data to a particular URI and expects the resource at that URI to deal with the request. The web server at this point can decide what to do with the data in the context of specified resource

PUT is idempotent meaning, invoking it any number of times will not have an impact on resources.

However, POST is not idempotent, meaning if you invoke POST multiple times it keeps creating more resources

Source: career.guru99.com

Q31: Name some best practices for better RESTful API design ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: What is meant by the KISS principle? ⭐⭐

Answer: KISS, a backronym for "keep it simple, stupid", is a design principle noted by the U.S. Navy in 1960. The KISS principle states that most systems work best if they are kept simple rather than made complicated; therefore simplicity should be a key goal in design, and that unnecessary complexity should be avoided.

Source: stackoverflow.com

Q33: What Is Load Balancing? ⭐⭐⭐

Answer:

Load balancing is simple technique for distributing workloads across multiple machines or clusters. The most common and simple load balancing algorithm is Round Robin. In this type of load balancing the request is divided in circular order ensuring all machines get equal number of requests and no single machine is overloaded or underloaded.

The Purpose of load balancing is to

  • Optimize resource usage (avoid overload and under-load of any machines)
  • Achieve Maximum Throughput
  • Minimize response time

Most common load balancing techniques in web based applications are

  1. Round robin
  2. Session affinity or sticky session
  3. IP Address affinity

Source: fromdev.com

Q34: What does SOLID stand for? What are its principles? ⭐⭐⭐

Answer: S.O.L.I.D is an acronym for the first five object-oriented design (OOD) principles by Robert C. Martin.

  • S - Single-responsiblity principle. A class should have one and only one reason to change, meaning that a class should have only one job.
  • O - Open-closed principle. Objects or entities should be open for extension, but closed for modification.
  • L - Liskov substitution principle. Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.
  • I - Interface segregation principle. A client should never be forced to implement an interface that it doesn't use or clients shouldn't be forced to depend on methods they do not use.
  • D - Dependency Inversion Principle. Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.

Source: scotch.io

Q35: Are you familiar with The Twelve-Factor App principles? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q36: Name some basic design elements ⭐

Answer: The elements of design are:

  • LINE – The linear marks made with a pen or brush or the edge created when two shapes meet.
  • SHAPE – A shape is a self contained defined area of geometric (squares and circles), or organic (free formed shapes or natural shapes). A positive shape automatically creates a negative shape.
  • DIRECTION – All lines have direction – Horizontal, Vertical or Oblique. Horizontal suggests calmness, stability and tranquillity. Vertical gives a feeling of balance, formality and alertness. Oblique suggests movement and action
  • SIZE – Size is simply the relationship of the area occupied by one shape to that of another.
  • TEXTURE – Texture is the surface quality of a shape – rough, smooth, soft hard glossy etc.
  • COLOUR – Colour is light reflected off objects. Color has three main characteristics: hue or its name (red, green, blue, etc.), value (how light or dark it is), and intensity (how bright or dull it is).

Source: j6design.com.au

Q37: What is User Centered Design? ⭐⭐

Answer: User-centered design is an iterative design process in which designers focus on the users and their needs in each phase of the design process. UCD calls for involving users throughout the design process via a variety of research and design techniques so as to create highly usable and accessible products for them.

User-centered design demands that designers employ a mixture of investigative (e.g., surveys and interviews) and generative (e.g., brainstorming) methods and tools to develop an understanding of user needs.

Source: interaction-design.org

Q38: Name fundamental principles of design ⭐⭐⭐

Answer: The fundamental principles of design are:

  • BALANCE — Balance in design is similar to balance in physics. A large shape close to the center can be balanced by a small shape close to the edge. Balance provides stability and structure to a design. It’s the weight distributed in the design by the placement of your elements.
  • PROXIMITY — Proximity creates a relationship between elements. It provides a focal point. Proximity doesn’t mean that elements have to be placed together, it means they should be visually connected in some way.
  • ALIGNMENT — Allows us to create order and organization. Aligning elements allows them to create a visual connection with each other.
  • REPETITION — Repetition strengthens a design by tying together individual elements. It helps to create association and consistency. Repetition can create rhythm (a feeling of organized movement).
  • CONTRAST — Contrast is the juxtaposition of opposing elements (opposite colors on the color wheel, or value light/dark, or direction — horizontal/vertical). Contrast allows us to emphasize or highlight key elements in your design.
  • SPACE — Space in art refers to the distance or area between, around, above, below, or within elements. Both positive and negative space are important factors to be considered in every design.

Source: uxplanet.org

Q39: What is SQL injection? ⭐

Answer: Injection attacks stem from a lack of strict separation between program instructions (i.e., code) and user-provided (or external) input. This allows an attacker to inject malicious code into a data snippet.

SQL injection is one of the most common types of injection attack. To carry it out, an attacker provides malicious SQL statements through the application.

How to prevent:

  • Prepared statements with parameterized queries
  • Stored procedures
  • Input validation - blacklist validation and whitelist validation
  • Principle of least privilege - Application accounts shouldn’t assign DBA or admin type access onto the database server. This ensures that if an application is compromised, an attacker won’t have the rights to the database through the compromised application.

Source: https://www.synopsys.com

Q40: What is Cross-Site Scripting (XSS)? ⭐⭐

Answer: Cross-Site Scripting (XSS) is an attack that occurs when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user.

The page provided by the server when someone requests it is unaltered. Instead, an XSS attack exploits a weakness in a page that include a variable submitted in a request to show up in raw form in the response. The page is only reflecting back what was submitted in that request.

Source: synopsys.com

Q41: What is Content Security Policy? ⭐⭐

Answer: Content Security Policy (CSP) is an HTTP header that allows site operators fine-grained control over where resources on their site can be loaded from. The use of this header is the best method to prevent cross-site scripting (XSS) vulnerabilities. Due to the difficulty in retrofitting CSP into existing websites, CSP is mandatory for all new websites and is strongly recommended for all existing high-risk sites.

The primary benefit of CSP comes from disabling the use of unsafe inline JavaScript. Inline JavaScript – either reflected or stored – means that improperly escaped user-inputs can generate code that is interpreted by the web browser as JavaScript. By using CSP to disable inline JavaScript, you can effectively eliminate almost all XSS attacks against your site.

Source: infosec.mozilla.org

Q42: What is ClickJacking? ⭐⭐⭐

Answer: ClickJacking is an attack that fools users into thinking they are clicking on one thing when they are actually clicking on another. The attack is possible thanks to HTML frames (iframes).

Its other name, user interface (UI) redressing, better describes what is going on. Users think they are using a web page’s normal UI, but in fact there is a hidden UI in control; in other words, the UI has been redressed. When users click something they think is safe, the hidden UI performs a different action.

Source: synopsys.com

Q43: What is webpack? ⭐

Answer: Webpack is a build tool that puts all of your assets, including Javascript, images, fonts, and CSS, in a dependency graph. Webpack lets you use require() in your source code to point to local files, like images, and decide how they're processed in your final Javascript bundle, like replacing the path with a URL pointing to a CDN.

Source: blog.andrewray.me

Q44: Why and when should I Use Webpack? ⭐

Answer: If you're building a complex Front End application with many non-code static assets such as CSS, images, fonts, etc, then yes, Webpack will give you great benefits.

If your application is fairly small, and you don't have many static assets and you only need to build one Javascript file to serve to the client, then Webpack might be more overhead than you need.

Source: blog.andrewray.me

Q45: Why do we use jQuery? ⭐⭐

Answer: Due to following advantages.

  • Easy to use and learn.
  • Easily expandable.
  • Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
  • Easy to use for DOM manipulation and traversal.
  • Large pool of built in methods.
  • AJAX Capabilities.
  • Methods for changing or applying CSS, creating animations.
  • Event detection and handling.
  • Tons of plug-ins for all kind of needs.

Source: codeproject.com

Q46: How JavaScript and jQuery are different? ⭐⭐

Answer: JavaScript is a language While jQuery is a library built in the JavaScript language that helps to use the JavaScript language.

Source: codeproject.com

Q47: When would you use AngularJS vs jQuery? ⭐⭐⭐

Answer:

  • jQuery - is a library used for DOM Manipulations - Has nothing to do with models - don't have two-way binding feature - becomes complex and difficult to maintain when size of project increases - Sometimes you have to write more code to achieve the same functionality as in Angular

  • Angular - is a MVVM Framework - Used for creating SPA (Single Page Applications) - Has key features like routing, directives, two way data binding, models, dependency injection, unit tests etc - is modular - Maintainable, when project size increases - is Fast and many more.

Basically jQuery is a single tool (solves one specific problem: dom manipulation) where AngularJS is a whole toolbox with all kind of tools for different problems (routing, modelbindings, dom manipulation, etc.). Actually jqLite (subset of jQuery) is part of the AngularJS and you use it to solve the dom-manipulation thing.

Source: stackoverflow.com

Originally published on 👉 50 Common Web Developer Interview Questions [2020 Updated] | FullStack.Cafe

Q1: What is Sprint Planning? ⭐⭐

Answer: The work to be performed in the Sprint is planned at the Sprint Planning. This plan is created by the collaborative work of the entire Scrum Team.

Sprint Planning answers the following:

  • What can be delivered in the Increment resulting from the upcoming Sprint?
  • How will the work needed to deliver the Increment be achieved?

The Sprint Goal is an objective set for the Sprint that can be met through the implementation of Product Backlog.

Source: scrum.org

Q2: What is test driven development? ⭐⭐

Answer: Test driven development (TDD) is also known as test-driven design. In this method, developer first writes an automated test case which describes new function or improvement and then creates small codes to pass that test, and later re-factors the new code to meet the acceptable standards.

Source: career.guru99.com

Q3: What is blockchain? ⭐

Answer: Blockchain is a secure distributed ledger (data structure or database) that maintains a continuously growing list of ordered records, called “blocks”, that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.

By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".

Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority.

Source: en.wikipedia.org

Q4: What is DOM (Document Object Model) and how is it linked to CSS? ⭐⭐

Answer: The Document Object Model (DOM) is a cross-platform and language-independent application programming interface that treats an HTML, XHTML, or XML document as a tree structure wherein each node is an object representing a part of the document.

With the Document Object Model, programmers can create and build documents, navigate their structure, and add, modify, or delete elements and content. The DOM specifies interfaces which may be used to manage XML or HTML documents.

When a browser displays a document, it must combine the document's content with its style information. The browser converts HTML and CSS into the DOM (Document Object Model). The DOM represents the document in the computer's memory. It combines the document's content with its style.

Source: en.wikipedia.org

Q5: What is CSS selectors? Name some. ⭐⭐⭐

Answer: A CSS selector is the part of a CSS rule set that actually selects the content you want to style.

Consider some types of CSS selectors:

  • Universal selector: *
  • Element type selector: ul, td
  • ID Selector: #id
  • Class selector: .box
  • Descendant combinator: #id .box. The .box element doesn’t have to be an immediate child of #id.
  • Child combinator: #id > .box. Unlike the descendant combinator, there can’t be another element wrapping .box
  • General Sibling Combinator: ~
  • Adjacent Sibling Combinator: +. The difference from general sibling combinaltor is that the targeted element must be an immediate sibling, not just a general sibling.
  • Attribute Selector: input[type="text"]
  • Pseudo-class: a:hover. A pseudo-class uses a colon character to identify a pseudo-state that an element might be in.
  • Pseudo-element: .container::before. This selector inserts an imaginary element into the page, inside the targeted element, before its contents.

Source: sitepoint.com

Q6: How is responsive design different from adaptive design? ⭐⭐⭐

Answer: Both responsive and adaptive design attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage contexts, control mechanisms, and so on.

Responsive design works on the principle of flexibility — a single fluid website that can look good on any device. Responsive websites use media queries, flexible grids, and responsive images to create a user experience that flexes and changes based on a multitude of factors. Like a single ball growing or shrinking to fit through several different hoops.

Adaptive design is more like the modern definition of progressive enhancement. Instead of one flexible design, adaptive design detects the device and other features, and then provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics. The site detects the type of device used, and delivers the pre-set layout for that device. Instead of a single ball going through several different-sized hoops, you’d have several different balls to use depending on the hoop size.

Source: codeburst.io

Q7: What is Design Patterns and why anyone should use them? ⭐

Answer: Design patterns are a well-described solution to the most commonly encountered problems which occur during software development.

Design pattern represents the best practices evolved over a period of time by experienced software developers. They promote reusability which leads to a more robust and maintainable code.

Source: www.educba.com

Q8: What is Adapter Pattern? ⭐⭐⭐

Answer: Adapter pattern works as a bridge between two incompatible interfaces. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces (adaptees).


A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop.

Source: tutorialspoint.com

Q9: What is meant by Continuous Integration? ⭐

Answer: Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

Source: edureka.co

Q10: What does Containerization mean? ⭐⭐

Answer: Containerisation is a type of virtualization strategy that emerged as an alternative to traditional hypervisor-based virtualization.

In containerization, the operating system is shared by the different containers rather than cloned for each virtual machine. For example Docker provides a container virtualization platform that serves as a good alternative to hypervisor-based arrangements.

Source: linoxide.com

Q11: What is the purpose of the alt attribute on images? ⭐

Answer: The alt attribute provides alternative information for an image if a user cannot view it. The alt attribute should be used to describe any images except those which only serve a decorative purposes, in which case it should be left empty.

Source: developer.mozilla.org

Q12: What is the difference between span and div? ⭐⭐

Answer:

  • div is a block element
  • span is inline element

For bonus points, you could point out that it’s illegal to place a block element inside an inline element, and that while div can have a p tag, and a p tag can have a span, it is not possible for span to have a div or p tag inside.

Source: thatjsdude.com

Q13: Explain almost standard, full standard and quirks mode ⭐⭐⭐

Answer: There are now three modes used by the layout engines in web browsers: quirks mode, almost standards mode, and full standards mode.

  • In quirks mode, layout emulates nonstandard behavior in Navigator 4 and Internet Explorer 5. This is essential in order to support websites that were built before the widespread adoption of web standards.
  • In full standards mode, the behavior is (hopefully) the behavior described by the HTML and CSS specifications.
  • In almost standards mode, there are only a very small number of quirks implemented.

For HTML documents, browsers use a DOCTYPE in the beginning of the document to decide whether to handle it in quirks mode or standards mode.

Source: developer.mozilla.org

Q14: What is HTML5 Web Storage? Explain localStorage and sessionStorage. ⭐⭐⭐

Answer: With HTML5, web pages can store data locally within the user’s browser. The data is stored in name/value pairs, and a web page can only access data stored by itself.

Differences between localStorage and sessionStorage regarding lifetime:

  • Data stored through localStorage is permanent: it does not expire and remains stored on the user’s computer until a web app deletes it or the user asks the browser to delete it.
  • sessionStorage has the same lifetime as the top-level window or browser tab in which the data got stored. When the tab is permanently closed, any data stored through sessionStorage is deleted.

Differences between localStorage and sessionStorage regarding storage scope:

Both forms of storage are scoped to the document origin so that documents with different origins will never share the stored objects.

  • sessionStorage is also scoped on a per-window basis. Two browser tabs with documents from the same origin have separate sessionStorage data.
  • Unlike in localStorage, the same scripts from the same origin can't access each other's sessionStorage when opened in different tabs.

Source: w3schools.com

Q15: What is progressive rendering? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q16: What is Coercion in JavaScript?

Answer: In JavaScript conversion between different two build-in types called coercion. Coercion comes in two forms in JavaScript: explicit and implicit.

Here's an example of explicit coercion:

var a = "42";

var b = Number( a );

a;				// "42"
b;				// 42 -- the number!

And here's an example of implicit coercion:

var a = "42";

var b = a * 1;	// "42" implicitly coerced to 42 here

a;				// "42"
b;				// 42 -- the number!

Q17: What is Scope in JavaScript? ⭐

Answer: In JavaScript, each function gets its own scope. Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function's scoped variables.

A variable name has to be unique within the same scope. A scope can be nested inside another scope. If one scope is nested inside another, code inside the innermost scope can access variables from either scope.

Q18: Explain equality in JavaScript ⭐

Answer: JavaScript has both strict and type–converting comparisons:

  • Strict comparison (e.g., ===) checks for value equality without allowing coercion
  • Abstract comparison (e.g. ==) checks for value equality with coercion allowed
var a = "42";
var b = 42;

a == b;			// true
a === b;		// false

Some simple equalityrules:

  • If either value (aka side) in a comparison could be the true or false value, avoid == and use ===.
  • If either value in a comparison could be of these specific values (0, "", or [] -- empty array), avoid == and use ===.
  • In all other cases, you're safe to use ==. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.

Q19: Explain Null and Undefined in JavaScript ⭐⭐

Answer: JavaScript (and by extension TypeScript) has two bottom types: null and undefined. They are intended to mean different things:

  • Something hasn't been initialized : undefined.
  • Something is currently unavailable: null.

Q20: Implement enqueue and dequeue using only two stacks ⭐⭐

Answer: Enqueue means to add an element, dequeue to remove an element.

var inputStack = []; // First stack
var outputStack = []; // Second stack

// For enqueue, just push the item into the first stack
function enqueue(stackInput, item) {
  return stackInput.push(item);
}

function dequeue(stackInput, stackOutput) {
  // Reverse the stack such that the first element of the output stack is the
  // last element of the input stack. After that, pop the top of the output to
  // get the first element that was ever pushed into the input stack
  if (stackOutput.length <= 0) {
    while(stackInput.length > 0) {
      var elementToOutput = stackInput.pop();
      stackOutput.push(elementToOutput);
    }
  }

  return stackOutput.pop();
}

Source: https://github.com/kennymkchan

Q21: What does "use strict" do? ⭐⭐

Answer: The use strict literal is entered at the top of a JavaScript program or at the top of a function and it helps you write safer JavaScript code by throwing an error if a global variable is created by mistake. For example, the following program will throw an error:

function doSomething(val) {
  "use strict"; 
  x = val + 10;
}`

It will throw an error because x was not defined and it is being set to some value in the global scope, which isn't allowed with use strict The small change below fixes the error being thrown:

function doSomething(val) {
  "use strict"; 
  var x = val + 10;
}

Source: coderbyte.com

Q22: How to compare two objects in JavaScript? ⭐⭐⭐

Answer: Two non-primitive values, like objects (including function and array) held by reference, so both == and === comparisons will simply check whether the references match, not anything about the underlying values.

For example, arrays are by default coerced to strings by simply joining all the values with commas (,) in between. So two arrays with the same contents would not be == equal:

var a = [1,2,3];
var b = [1,2,3];
var c = "1,2,3";

a == c;		// true
b == c;		// true
a == b;		// false

For deep object comparison use external libs like deep-equal or implement your own recursive equality algorithm.

Q23: Could you explain the difference between ES5 and ES6 ⭐⭐⭐

Answer:

  • ECMAScript 5 (ES5): The 5th edition of ECMAScript, standardized in 2009. This standard has been implemented fairly completely in all modern browsers

  • ECMAScript 6 (ES6)/ ECMAScript 2015 (ES2015): The 6th edition of ECMAScript, standardized in 2015. This standard has been partially implemented in most modern browsers.

Here are some key differences between ES5 and ES6:

  • Arrow functions & string interpolation:
    Consider:
const greetings = (name) => {
      return `hello ${name}`;
}

and even:

const greetings = name => `hello ${name}`;
  • Const.
    Const works like a constant in other languages in many ways but there are some caveats. Const stands for ‘constant reference’ to a value. So with const, you can actually mutate the properties of an object being referenced by the variable. You just can’t change the reference itself.
const NAMES = [];
NAMES.push("Jim");
console.log(NAMES.length === 1); // true
NAMES = ["Steve", "John"]; // error
  • Block-scoped variables.
    The new ES6 keyword let allows developers to scope variables at the block level. Let doesn’t hoist in the same way var does.
  • Default parameter values Default parameters allow us to initialize functions with default values. A default is used when an argument is either omitted or undefined — meaning null is a valid value.
// Basic syntax
function multiply (a, b = 2) {
     return a * b;
}
multiply(5); // 10
  • ** Class Definition and Inheritance**
    ES6 introduces language support for classes (class keyword), constructors (constructor keyword), and the extend keyword for inheritance.

  • for-of operator
    The for...of statement creates a loop iterating over iterable objects.

  • Spread Operator For objects merging

const obj1 = { a: 1, b: 2 }
const obj2 = { a: 2, c: 3, d: 4}
const obj3 = {...obj1, ...obj2}
  • Promises
    Promises provide a mechanism to handle the results and errors from asynchronous operations. You can accomplish the same thing with callbacks, but promises provide improved readability via method chaining and succinct error handling.
const isGreater = (a, b) => {
  return new Promise ((resolve, reject) => {
    if(a > b) {
      resolve(true)
    } else {
      reject(false)
    }
    })
}
isGreater(1, 2)
  .then(result => {
    console.log('greater')
  })
 .catch(result => {
    console.log('smaller')
 })
  • Modules exporting & importing Consider module exporting:
const myModule = { x: 1, y: () => { console.log('This is ES5') }}
export default myModule;

and importing:

import myModule from './myModule';

Q24: Given two strings, return true if they are anagrams of one another ⭐⭐⭐

Details: For example: Mary is an anagram of Army

Answer:

var firstWord = "Mary";
var secondWord = "Army";

isAnagram(firstWord, secondWord); // true

function isAnagram(first, second) {
  // For case insensitivity, change both words to lowercase.
  var a = first.toLowerCase();
  var b = second.toLowerCase();

  // Sort the strings, and join the resulting array to a string. Compare the results
  a = a.split("").sort().join("");
  b = b.split("").sort().join("");

  return a === b;
}

Source: https://github.com/kennymkchan

Q25: What is IIFEs (Immediately Invoked Function Expressions)? ⭐⭐⭐

Answer: It’s an Immediately-Invoked Function Expression, or IIFE for short. It executes immediately after it’s created:

(function IIFE(){
	console.log( "Hello!" );
})();
// "Hello!"

This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.

Source: stackoverflow.com

Q26: What are the advantages and disadvantages of using "use strict"? ⭐⭐⭐

Answer: 'use strict' is a statement used to enable strict mode to entire scripts or individual functions. Strict mode is a way to opt into a restricted variant of JavaScript.

Advantages:

  • Makes it impossible to accidentally create global variables.
  • Makes assignments which would otherwise silently fail to throw an exception.
  • Makes attempts to delete undeletable properties throw (where before the attempt would simply have no effect).
  • Requires that function parameter names be unique.
  • this is undefined in the global context.
  • It catches some common coding bloopers, throwing exceptions.
  • It disables features that are confusing or poorly thought out.

Disadvantages:

  • Many missing features that some developers might be used to.
  • No more access to function.caller and function.arguments.
  • Concatenation of scripts written in different strict modes might cause issues.

Overall, I think the benefits outweigh the disadvantages, and I never had to rely on the features that strict mode blocks. I would recommend using strict mode.

Source: github.com/yangshun

Q27: Explain the difference between Object.freeze() vs const ⭐⭐⭐

Answer: const and Object.freeze are two completely different things.

  • const applies to bindings ("variables"). It creates an immutable binding, i.e. you cannot assign a new value to the binding.
const person = {
    name: "Leonardo"
};
let animal = {
    species: "snake"
};
person = animal; // ERROR "person" is read-only
  • Object.freeze works on values, and more specifically, object values. It makes an object immutable, i.e. you cannot change its properties.
let person = {
    name: "Leonardo"
};
let animal = {
    species: "snake"
};
Object.freeze(person);
person.name = "Lima"; //TypeError: Cannot assign to read only property 'name' of object
console.log(person);

Source: stackoverflow.com

Q28: What is Hoisting in JavaScript? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q29: How does the “this” keyword work? Provide some code examples. ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q30: Write a recursive function that performs a binary search ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q31: What is “closure” in javascript? Provide an example? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q32: Explain difference between: function Person(){}, var person = Person(), and var person = new Person()? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q33: What are the features of Microservices? ⭐⭐⭐

Answer:

  • Decoupling – Services within a system are largely decoupled. So the application as a whole can be easily built, altered, and scaled
  • Componentization – Microservices are treated as independent components that can be easily replaced and upgraded
  • Business Capabilities – Microservices are very simple and focus on a single capability
  • Autonomy – Developers and teams can work independently of each other, thus increasing speed
  • Continous Delivery – Allows frequent releases of software, through systematic automation of software creation, testing, and approval
  • Responsibility – Microservices do not focus on applications as projects. Instead, they treat applications as products for which they are responsible
  • Decentralized Governance – The focus is on using the right tool for the right job. That means there is no standardized pattern or any technology pattern. Developers have the freedom to choose the best useful tools to solve their problems
  • Agility – Microservices support agile development. Any new feature can be quickly developed and discarded again

Source: lambdatest.com

Q34: What is npm? ⭐

Answer: npm stands for Node Package Manager. npm provides following two main functionalities:

  • Online repositories for node.js packages/modules which are searchable on search.nodejs.org
  • Command line utility to install packages, do version management and dependency management of Node.js packages.

Source: tutorialspoint.com

Q35: What is the difference between procedural and object-oriented programming? ⭐⭐

Answer: Procedural programming is based upon the modular approach in which the larger programs are broken into procedures. Each procedure is a set of instructions that are executed one after another. On the other hand, OOP is based upon objects. An object consists of various elements, such as methods and variables.

Access modifiers are not used in procedural programming, which implies that the entire data can be accessed freely anywhere in the program. In OOP, you can specify the scope of a particular data by using access modifiers - public, private, internal, protected, and protected internal.

Source: indiabix.com

Q36: State the features of an interface. ⭐⭐⭐

Answer: An interface is a template that contains only the signature of methods. The signature of a method consists of the numbers of parameters, the type of parameter (value, reference, or output), and the order of parameters. An interface has no implementation on its own because it contains only the definition of methods without any method body. An interface is defined using the interface keyword. Moreover, you cannot instantiate an interface. The various features of an interface are as follows:

  • An interface is used to implement multiple inheritance in code. This feature of an interface is quite different from that of abstract classes because a class cannot derive the features of more than one class but can easily implement multiple interfaces.
  • It defines a specific set of methods and their arguments.
  • Variables in interface must be declared as public, static, and final while methods must be public and abstract.
  • A class implementing an interface must implement all of its methods.
  • An interface can derive from more than one interface.

Source: indiabix.com

Q37: What is the difference between cohesion and coupling? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q38: What does it mean to “program to an interface”? ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q39: What is Reactive Programming? ⭐⭐

Answer: Reactive programming is programming with asynchronous data streams. Event buses or your typical click events are really an asynchronous event stream, on which you can observe and do some side effects. Reactive is that idea on steroids. You are able to create data streams of anything, not just from click and hover events. Streams are cheap and ubiquitous, anything can be a stream: variables, user inputs, properties, caches, data structures, etc. For example, imagine your Twitter feed would be a data stream in the same fashion that click events are. You can listen to that stream and react accordingly.

Source: github.com

Q40: What are different HTTP Methods supported in Restful Web Services? ⭐⭐

Answer: Restful web services supported HTTP methods are:

  • GET,
  • POST,
  • PUT,
  • DELETE and
  • HEAD.

Source: journaldev.com

Q41: How would you choose between SOAP and REST web services? ⭐⭐⭐

Answer: Web Services work on client-server model and when it comes to choose between SOAP and REST, it all depends on project requirements. Let’s look at some of the conditions affecting our choice:

  • Do you know your web service clients beforehand? If Yes, then you can define a contract before implementation and SOAP seems better choice. But if you don’t then REST seems better choice because you can provide sample request/response and test cases easily for client applications to use later on.
  • How much time you have? For quick implementation REST is the best choice. You can create web service easily, test it through browser/curl and get ready for your clients. What kind of data format are supported? If only XML then you can go with SOAP but if you think about supporting JSON also in future then go with REST.

Source: journaldev.com

Q42: What are the best practices for caching? ⭐⭐⭐

Answer: Always keep static contents like images, css, JavaScript cacheable, with expiration date of 2 to 3 days. Never keep expiry date too high.

Dynamic contents should be cached for few hours only.

Source: tutorialspoint.com

Q43: What should be the purpose of OPTIONS method of RESTful web services? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q44: What are the DRY and DIE principles? ⭐⭐⭐

Answer: In software engineering, Don't Repeat Yourself (DRY) or Duplication is Evil (DIE) is a principle of software development.

Source: stackoverflow.com

Q45: What is GOD class and why should we avoid it? ⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Q46: What is CORS and how to enable one? ⭐⭐

Answer: A request for a resource (like an image or a font) outside of the origin is known as a cross-origin request. CORS (cross-origin resource sharing) manages cross-origin requests. CORS allows servers to specify who (i.e., which origins) can access the assets on the server, among many other things.

Access-Control-Allow-Origin is an HTTP header that defines which foreign origins are allowed to access the content of pages on your domain via scripts using methods such as XMLHttpRequest.

For example, if your server provides both a website and an API intended for XMLHttpRequest access on a remote websites, only the API resources should return the Access-Control-Allow-Origin header. Failure to do so will allow foreign origins to read the contents of any page on your origin.

# Allow any site to read the contents of this JavaScript library, so that subresource integrity works
Access-Control-Allow-Origin: *

Source: infosec.mozilla.org

Q47: What is Cross Site Scripting (XSS)? ⭐⭐

Answer: By using Cross Site Scripting (XSS) technique, users executed malicious scripts (also called payloads) unintentionally by clicking on untrusted links and hence, these scripts pass cookies information to attackers.

Source: allabouttesting.org

Q48: How can I prevent XSS? ⭐⭐

Answer: XSS can be prevented by sanitizing user input to the application. Always allowed those elements as input which is absolutely essential for that field.

Source: allabouttesting.org

Q49: What is webpack? ⭐

Answer: Webpack is a build tool that puts all of your assets, including Javascript, images, fonts, and CSS, in a dependency graph. Webpack lets you use require() in your source code to point to local files, like images, and decide how they're processed in your final Javascript bundle, like replacing the path with a URL pointing to a CDN.

Source: blog.andrewray.me

Q50: Describe tree shaking mechanism in webpack ⭐⭐⭐⭐⭐

Answer: Read Full Answer on 👉 FullStack.Cafe

Originally published on 👉 50 Junior Web Developer Interview Questions. The Ultimate 2018 Guide. | FullStack.Cafe

Q1: Explain what is Bootstrap? ⭐

Answer: Bootstrap is CSS/Javascript framework for building the rich web applications with minimal effort. This framework emphasis more on building mobile web applications.

Source: medium.com/@alisonbenhar

Q2: Explain the three main ways to apply CSS styles to a web page ⭐

Answer: Using the inline style attribute on an element

<div>
    <p style="color: maroon;"></p>
</div>

Using a <style> block in the <head> section of your HTML

<head>
    <title>CSS Refresher</title>
    <style>
        body {
            font-family: sans-serif;
            font-size: 1.2em;
        }
    </style>
</head>

Loading an external CSS file using the <link> tag

<head>
    <title>CSS Refresher</title>
    <link rel="stylesheet" href="/css/styles.css" />
</head>

Source: goskills.com

Q3: What is CSS? ⭐

Answer: CSS stands for Cascading Style Sheets. CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.

CSS was intended to allow web professionals to separate the content and structure of a website's code from the visual design.

Source: w3schools.com

Q4: Explain the CSS “box model” and the layout components that it consists of ⭐⭐

Answer: The CSS box model is a rectangular layout paradigm for HTML elements that consists of the following:

  • Content - The content of the box, where text and images appear
  • Padding - A transparent area surrounding the content (i.e., the amount of space between the border and the content)
  • Border - A border surrounding the padding (if any) and content
  • Margin - A transparent area surrounding the border (i.e., the amount of space between the border and any neighboring elements)

Source: toptal.com

Q5: Describe floats and how they work ⭐⭐

Answer: Float is a CSS positioning property. Floated elements remain a part of the flow of the web page. This is distinctly different than page elements that use absolute positioning. Absolutely positioned page elements are removed from the flow of the webpage.

#sidebar {
  float: right; // left right none inherit			
}

The CSS clear property can be used to be positioned below left/right/both floated elements.

Source: css-tricks.com

Q6: Have you played around with the new CSS Flexbox or Grid specs? ⭐⭐

Answer: Yes. Flexbox is mainly meant for 1-dimensional layouts while Grid is meant for 2-dimensional layouts.

Flexbox solves many common problems in CSS, such as vertical centering of elements within a container, sticky footer, etc. Bootstrap and Bulma are based on Flexbox, and it is probably the recommended way to create layouts these days. Have tried Flexbox before but ran into some browser incompatibility issues (Safari) in using flex-grow, and I had to rewrite my code using inline-blocks and math to calculate the widths in percentages, it wasn't a nice experience.

Grid is by far the most intuitive approach for creating grid-based layouts (it better be!) but browser support is not wide at the moment.

Source: codeburst.io

Q7: What existing CSS frameworks have you used locally, or in production? How would you change/improve them? ⭐⭐

Answer:

  • Bootstrap - Slow release cycle. Bootstrap 4 has been in alpha for almost 2 years. Add a spinner button component, as it is widely used.
  • Semantic UI - Source code structure makes theme customization extremely hard to understand. Its unconventional theming system is a pain to customize. Hardcoded config path within the vendor library. Not well-designed for overriding variables unlike in Bootstrap.
  • Bulma - A lot of non-semantic and superfluous classes and markup required. Not backward compatible. Upgrading versions breaks the app in subtle manners.

Source: codeburst.io

Q8: What is DOM (Document Object Model) and how is it linked to CSS? ⭐⭐

Answer: The Document Object Model (DOM) is a cross-platform and language-independent application programming interface that treats an HTML, XHTML, or XML document as a tree structure wherein each node is an object representing a part of the document.

With the Document Object Model, programmers can create and build documents, navigate their structure, and add, modify, or delete elements and content. The DOM specifies interfaces which may be used to manage XML or HTML documents.

When a browser displays a document, it must combine the document's content with its style information. The browser converts HTML and CSS into the DOM (Document Object Model). The DOM represents the document in the computer's memory. It combines the document's content with its style.

Source: en.wikipedia.org

Q9: What is CSS preprocessor and why to user one? ⭐⭐⭐

Answer: A CSS preprocessor is a program that lets you generate CSS from the preprocessor's own unique syntax. There are many CSS preprocessors to choose from, however most CSS preprocessors will add some features that don't exist in pure CSS, such as mixin, nesting selector, inheritance selector, and so on. These features make the CSS structure more readable and easier to maintain.

Here are a few of the most popular CSS preprocessors:

  • SASS (SCSS)
  • LESS
  • Stylus
  • PostCSS

Source: developer.mozilla.org

Q10: How to create a zebra striped table with CSS? ⭐⭐⭐

Answer: To create a zebra-striped table, use the nth-child() selector and add a background-color to all even (or odd) table rows:

tr:nth-child(even) {
    background-color: #f2f2f2
}

Source: w3schools.com

Q11: What is a Grid System in CSS? ⭐⭐⭐

Answer: A grid system is a structure that allows for content to be stacked both vertically and horizontally in a consistent and easily manageable fashion. Grid systems include two key components: rows and columns.

Some Grid Systems:

  • Simple Grid
  • Pure
  • Flexbox Grid
  • Bootstrap
  • Foundation

Source: sitepoint.com

Q12: What is Singleton pattern? ⭐

Answer: Singleton pattern comes under creational patterns category and introduces a single class which is responsible to create an object while making sure that only single object gets created. This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class.

Source: refactoring.guru

Q13: What is Dependency Injection? ⭐⭐

Answer: Dependency injection makes it easy to create loosely coupled components, which typically means that components consume functionality defined by interfaces without having any first-hand knowledge of which implementation classes are being used.

Dependency injection makes it easier to change the behavior of an application by changing the components that implement the interfaces that define application features. It also results in components that are easier to isolate for unit testing.

Source: Pro ASP.NET Core MVC 2

Q14: What is Observer pattern? ⭐⭐⭐

Answer: Observer pattern (also known as Publish-Subscribe Pattern) is used when there is one-to-many relationship between objects such as if one object is modified, its dependent objects are to be notified automatically. Observer pattern falls under behavioral pattern category.

An object with a one-to-many relationship with other objects who are interested in its state is called the subject or publisher. The observers are notified whenever the state of the subject changes and can act accordingly. The subject can have any number of dependent observers which it notifies, and any number of observers can subscribe to the subject to receive such notifications.

Observer pattern uses two actor classes:

  • The Observer (os Subscriber) abstract class provides an update() method which will be called by the subject to notify it of the subject’s state change.
  • The Subject (or Publisher) class is also an abstract class and defines four primary methods: attach(), detach(), setState(), and notify()

Source: sitepoint.com

Q15: What is meant by Continuous Integration? ⭐

Answer: Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

Source: edureka.co

Q16: What do you know about serverless model? ⭐⭐⭐

Answer: Serverless refers to a model where the existence of servers is hidden from developers. It means you no longer have to deal with capacity, deployments, scaling and fault tolerance and OS. It will essentially reducing maintenance efforts and allow developers to quickly focus on developing codes.

Examples are:

  • Amazon AWS Lambda
  • Azure Functions

Source: linoxide.com

Q17: What is Git? ⭐

Answer: Git is a Distributed Version Control system (DVCS). It can track changes to a file and allows you to revert back to any particular change.

Its distributed architecture provides many advantages over other Version Control Systems (VCS) like SVN one major advantage is that it does not rely on a central server to store all the versions of a project’s files.

Source: edureka.co

Q18: How does the Centralized Workflow work? ⭐⭐

Answer: The Centralized Workflow uses a central repository to serve as the single point-of-entry for all changes to the project. The default development branch is called master and all changes are committed into this branch.

Developers start by cloning the central repository. In their own local copies of the project, they edit files and commit changes. These new commits are stored locally.

To publish changes to the official project, developers push their local master branch to the central repository. Before the developer can publish their feature, they need to fetch the updated central commits and rebase their changes on top of them.

Compared to other workflows, the Centralized Workflow has no defined pull request or forking patterns.

Source: atlassian.com

Q19: You need to update your local repos. What git commands will you use? ⭐⭐

Answer: It’s a two steps process. First you fetch the changes from a remote named origin:

git fetch origin

Then you merge a branch master to local:

git merge origin/master

Or simply:

git pull origin master

If origin is a default remote and ‘master’ is default branch, you can drop it eg. git pull.

Source: samwize.com

Q20: Could you explain the Gitflow workflow? ⭐⭐⭐

Answer: Gitflow workflow employs two parallel long-running branches to record the history of the project, master and develop:

  • Master - is always ready to be released on LIVE, with everything fully tested and approved (production-ready).

  • Hotfix - Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a lot like release branches and feature branches except they're based on master instead of develop.

  • Develop - is the branch to which all feature branches are merged and where all tests are performed. Only when everything’s been thoroughly checked and fixed it can be merged to the master.

  • Feature - Each new feature should reside in its own branch, which can be pushed to the develop branch as their parent one.

Source: atlassian.com

Q21: Explain meta tags in HTML ⭐

Answer:

  • Meta tags always go inside head tag of the HTML page
  • Meta tags is always passed as name/value pairs
  • Meta tags are not displayed on the page but intended for the browser
  • Meta tags can contain information about character encoding, description, title of the document etc,

Example:

<!DOCTYPE html>
<html>
<head>
  <meta name="description" content="I am a web page with description"> 
  <title>Home Page</title>
</head>
<body>
  
</body>
</html>

Source: github.com/FuelFrontend

Q22: Write a HTML table tag sequence that outputs the following ⭐

Answer: Write a HTML table tag sequence that outputs the following:

50 pcs 100 500
10 pcs 5 50

Answer:

<table>
  <tr>
    <td>50 pcs</td>
    <td>100</td>
    <td>500</td>
  </tr>
  <tr>
    <td>10 pcs</td>
    <td>5</td>
    <td>50</td>
  </tr>
</table>

Source: toptal.com

Q23: What is the difference between span and div? ⭐⭐

Answer:

  • div is a block element
  • span is inline element

For bonus points, you could point out that it’s illegal to place a block element inside an inline element, and that while div can have a p tag, and a p tag can have a span, it is not possible for span to have a div or p tag inside.

Source: thatjsdude.com

Q24: How Can I Get Indexed Better by Search Engines? ⭐⭐

Answer: It is possible to get indexed better by placing the following two statements in the <HEAD> part of your documents:

<META NAME="keywords" CONTENT="keyword keyword keyword keyword">
<META NAME="description" CONTENT="description of your site">

Both may contain up to 1022 characters. If a keyword is used more than 7 times, the keywords tag will be ignored altogether. Also, you cannot put markup (other than entities) in the description or keywords list.

Source: freejavaguide.com

Q25: Explain the difference between cookies, session and local storage ⭐⭐⭐

Answer: Cookies

  • Limited storage space 4096 bytes / ~4 kb
  • Only allow to store data as strings
  • Stored data is sent back to server on every HTTP request such as HTML, CSS, Images etc,
  • Can store only 20 cookies per domain
  • In total 300 cookies are allowed on a site
  • Setting HTTP only flag will prevent accessing cookies via javascript
  • Can set expiration duration for auto deletion (can be set either from server or client)

Example:

// Set with expiration & path
document.cookie = "name=Gokul; expires=Thu, 18 Dec 2016 12:00:00 UTC; path=/;";

// Get
document.cookie;

// Delete by setting empty value and same path
document.cookie = "name=; expires=Thu, 18 Dec 2016 12:00:00 UTC; path=/;";

Session Storage

  • Storage space is 5 mb / ~5120 kb
  • Storage space may vary a little based on the browser
  • Only allow to store data as strings
  • Data is available per window or tab
  • Once window or tab is closed stored data is deleted
  • Data will be only available on same origin

Example:

// Set
sessionStorage.setItem("name", "gokul");

// Get
sessionStorage.getItem("name"); // gokul

// Delete
sessionStorage.removeItem("name"); 

// Delete All
sessionStorage.clear();

Local Storage

  • Storage space is 5 mb / ~5120 kb
  • Storage space may vary a little based on the browser
  • Only allow to store data as strings
  • Data will be only available on same origin
  • Data is persistant (untill explicitly deleted)
  • API is similar to session storage

Example:

// Set
localStorage.setItem("name", "gokul");

// Get
localStorage.getItem("name"); // gokul

// Delete
localStorage.removeItem("name"); 

// Delete All
localStorage.clear();

Source: github.com/FuelFrontend

Q26: What's new in HTML 5? ⭐⭐⭐

Answer: HTML 5 adds a lot of new features to the HTML specification

New Doctype

Still using that pesky, impossible-to-memorize XHTML doctype?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If so, why? Switch to the new HTML5 doctype. You'll live longer -- as Douglas Quaid might say.

<!DOCTYPE html>

New Structure

  • <section> - to define sections of pages
  • <header> - defines the header of a page
  • <footer> - defines the footer of a page
  • <nav> - defines the navigation on a page
  • <article> - defines the article or primary content on a page
  • <aside> - defines extra content like a sidebar on a page
  • <figure> - defines images that annotate an article

New Inline Elements

These inline elements define some basic concepts and keep them semantically marked up, mostly to do with time:

  • <mark> - to indicate content that is marked in some fashion
  • <time> - to indicate content that is a time or date
  • <meter> - to indicate content that is a fraction of a known range - such as disk usage
  • <progress> - to indicate the progress of a task towards completion

New Form Types

  • <input type="datetime">
  • <input type="datetime-local">
  • <input type="date">
  • <input type="month">
  • <input type="week">
  • <input type="time">
  • <input type="number">
  • <input type="range">
  • <input type="email">
  • <input type="url">

New Elements

There are a few exciting new elements in HTML 5:

  • <canvas> - an element to give you a drawing space in JavaScript on your Web pages. It can let you add images or graphs to tool tips or just create dynamic graphs on your Web pages, built on the fly.
  • <video> - add video to your Web pages with this simple tag.
  • <audio> - add sound to your Web pages with this simple tag.

No More Types for Scripts and Links

You possibly still add the type attribute to your link and script tags.

<link rel="stylesheet" href="path/to/stylesheet.css" type="text/css" />
<script type="text/javascript" src="path/to/script.js"></script>

This is no longer necessary. It's implied that both of these tags refer to stylesheets and scripts, respectively. As such, we can remove the type attribute all together.

<link rel="stylesheet" href="path/to/stylesheet.css" />
<script src="path/to/script.js"></script>

Make your content editable

The new browsers have a nifty new attribute that can be applied to elements, called contenteditable. As the name implies, this allows the user to edit any of the text contained within the element, including its children. There are a variety of uses for something like this, including an app as simple as a to-do list, which also takes advantage of local storage.

<h2> To-Do List </h2>
<ul contenteditable="true">
  <li> Break mechanical cab driver. </li>
  <li> Drive to abandoned factory
  <li> Watch video of self </li>
</ul>

Attributes

  • require to mention the form field is required
  • autofocus puts the cursor on the input field

Source: github.com/FuelFrontend

Q27: What is the purpose of cache busting and how can you achieve it? ⭐⭐⭐

Answer: Browsers have a cache to temporarily store files on websites so they don't need to be re-downloaded again when switching between pages or reloading the same page. The server is set up to send headers that tell the browser to store the file for a given amount of time. This greatly increases website speed and preserves bandwidth.

However, it can cause problems when the website has been changed by developers because the user's cache still references old files. This can either leave them with old functionality or break a website if the cached CSS and JavaScript files are referencing elements that no longer exist, have moved or have been renamed.

Cache busting is the process of forcing the browser to download the new files. This is done by naming the file something different to the old file.

A common technique to force the browser to re-download the file is to append a query string to the end of the file.

  • src="js/script.js" => src="js/script.js?v=2"

The browser considers it a different file but prevents the need to change the file name.

Source: css-tricks.com

Q28: Explain equality in JavaScript ⭐

Answer: JavaScript has both strict and type–converting comparisons:

  • Strict comparison (e.g., ===) checks for value equality without allowing coercion
  • Abstract comparison (e.g. ==) checks for value equality with coercion allowed
var a = "42";
var b = 42;

a == b;			// true
a === b;		// false

Some simple equalityrules:

  • If either value (aka side) in a comparison could be the true or false value, avoid == and use ===.
  • If either value in a comparison could be of these specific values (0, "", or [] -- empty array), avoid == and use ===.
  • In all other cases, you're safe to use ==. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.

Q29: What is Scope in JavaScript? ⭐

Answer: In JavaScript, each function gets its own scope. Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function's scoped variables.

A variable name has to be unique within the same scope. A scope can be nested inside another scope. If one scope is nested inside another, code inside the innermost scope can access variables from either scope.

Q30: Explain event bubbling and how one may prevent it ⭐⭐

Answer: Event bubbling is the concept in which an event triggers at the deepest possible element, and triggers on parent elements in nesting order. As a result, when clicking on a child element one may exhibit the handler of the parent activating.

One way to prevent event bubbling is using event.stopPropagation() or event.cancelBubble on IE < 9.

Source: https://github.com/kennymkchan

Q31: Given a string, reverse each word in the sentence ⭐⭐

Details: For example Welcome to this Javascript Guide! should be become emocleW ot siht tpircsavaJ !ediuG

Answer:

var string = "Welcome to this Javascript Guide!";

// Output becomes !ediuG tpircsavaJ siht ot emocleW
var reverseEntireSentence = reverseBySeparator(string, "");

// Output becomes emocleW ot siht tpircsavaJ !ediuG
var reverseEachWord = reverseBySeparator(reverseEntireSentence, " ");

function reverseBySeparator(string, separator) {
  return string.split(separator).reverse().join(separator);
}

Source: https://github.com/kennymkchan

Q32: What does "use strict" do? ⭐⭐

Answer: The use strict literal is entered at the top of a JavaScript program or at the top of a function and it helps you write safer JavaScript code by throwing an error if a global variable is created by mistake. For example, the following program will throw an error:

function doSomething(val) {
  "use strict"; 
  x = val + 10;
}`

It will throw an error because x was not defined and it is being set to some value in the global scope, which isn't allowed with use strict The small change below fixes the error being thrown:

function doSomething(val) {
  "use strict"; 
  var x = val + 10;
}

Source: coderbyte.com

Q33: What is a Polyfill? ⭐⭐

Answer: A polyfill is essentially the specific code (or plugin) that would allow you to have some specific functionality that you expect in current or “modern” browsers to also work in other browsers that do not have the support for that functionality built in.

  • Polyfills are not part of the HTML5 standard
  • Polyfilling is not limited to Javascript

Source: programmerinterview.com

Q34: Explain Null and Undefined in JavaScript ⭐⭐

Answer: JavaScript (and by extension TypeScript) has two bottom types: null and undefined. They are intended to mean different things:

  • Something hasn't been initialized : undefined.
  • Something is currently unavailable: null.

Q35: What will be the output of the following code? ⭐⭐⭐

Details:

var y = 1;
if (function f() {}) {
  y += typeof f;
}
console.log(y);

Answer: Above code would give output 1undefined. If condition statement evaluate using eval so eval(function f() {}) which return function f() {} which is true so inside if statement code execute. typeof f return undefined because if statement code execute at run time, so statement inside if condition evaluated at run time.

var k = 1;
if (1) {
  eval(function foo() {});
  k += typeof foo;
}
console.log(k);

Above code will also output 1undefined.

var k = 1;
if (1) {
  function foo() {};
  k += typeof foo;
}
console.log(k); // output 1function

Source: github.com/ganqqwerty

Q36: How to compare two objects in JavaScript? ⭐⭐⭐

Answer: Two non-primitive values, like objects (including function and array) held by reference, so both == and === comparisons will simply check whether the references match, not anything about the underlying values.

For example, arrays are by default coerced to strings by simply joining all the values with commas (,) in between. So two arrays with the same contents would not be == equal:

var a = [1,2,3];
var b = [1,2,3];
var c = "1,2,3";

a == c;		// true
b == c;		// true
a == b;		// false

For deep object comparison use external libs like deep-equal or implement your own recursive equality algorithm.

Q37: Given two strings, return true if they are anagrams of one another ⭐⭐⭐

Details: For example: Mary is an anagram of Army

Answer:

var firstWord = "Mary";
var secondWord = "Army";

isAnagram(firstWord, secondWord); // true

function isAnagram(first, second) {
  // For case insensitivity, change both words to lowercase.
  var a = first.toLowerCase();
  var b = second.toLowerCase();

  // Sort the strings, and join the resulting array to a string. Compare the results
  a = a.split("").sort().join("");
  b = b.split("").sort().join("");

  return a === b;
}

Source: https://github.com/kennymkchan

Q38: Explain the difference between "undefined" and "not defined" in JavaScript ⭐⭐⭐

Answer: In JavaScript if you try to use a variable that doesn't exist and has not been declared, then JavaScript will throw an error var name is not defined and the script will stop execute thereafter. But If you use typeof undeclared_variable then it will return undefined.

Before starting further discussion let's understand the difference between declaration and definition.

var x is a declaration because you are not defining what value it holds yet, but you are declaring its existence and the need of memory allocation.

var x; // declaring x
console.log(x); //output: undefined

var x = 1 is both declaration and definition (also we can say we are doing initialisation), Here declaration and assignment of value happen inline for variable x, In JavaScript every variable declaration and function declaration brings to the top of its current scope in which it's declared then assignment happen in order this term is called hoisting.

A variable that is declared but not define and when we try to access it, It will result undefined.

var x; // Declaration
if(typeof x === 'undefined') // Will return true

A variable that neither declared nor defined when we try to reference such variable then It result not defined.

console.log(y);  // Output: ReferenceError: y is not defined

Source: stackoverflow.com

Q39: Describe closure concept in JavaScript as best as you could ⭐⭐⭐

Answer: Consider:

function makeAdder(x) {
	// parameter `x` is an inner variable

	// inner function `add()` uses `x`, so
	// it has a "closure" over `x`
	function add(y) {
		return y + x;
	};

	return add;
}

Reference to inner add function returned is able to remember what x value was passed to makeAdder function call.

var plusOne = makeAdder( 1 ); // x is 1, plusOne has a reference to add(y)
var plusTen = makeAdder( 10 ); // x is 10

plusOne(3); // 1 (x) + 3 (y) = 4
plusTen(13); // 10 (x) + 13 (y) = 23 

In C and most other common languages, after a function returns, all the local variables are no longer accessible because the stack-frame is destroyed.

In JavaScript, if you declare a function within another function, then the local variables can remain accessible after returning from the function you called.

A closure is a stack frame which is allocated when a function starts its execution, and not freed after the function returns (as if a 'stack frame' were allocated on the heap rather than the stack!). In JavaScript, you can think of a function reference variable as having both a pointer to a function as well as a hidden pointer to a closure.

Source: https://stackoverflow.com/questions/111102/how-do-javascript-closures-work

Q40: What is npm? ⭐

Answer: npm stands for Node Package Manager. npm provides following two main functionalities:

  • Online repositories for node.js packages/modules which are searchable on search.nodejs.org
  • Command line utility to install packages, do version management and dependency management of Node.js packages.

Source: tutorialspoint.com

Q41: What is Node.js? ⭐

Answer: Node.js is a web application framework built on Google Chrome's JavaScript Engine (V8 Engine).

Node.js comes with runtime environment on which a Javascript based script can be interpreted and executed (It is analogus to JVM to JAVA byte code). This runtime allows to execute a JavaScript code on any machine outside a browser. Because of this runtime of Node.js, JavaScript is now can be executed on server as well.

Node.js = Runtime Environment + JavaScript Library

Source: tutorialspoint.com

Q42: What is global installation of dependencies? ⭐⭐

Answer: Globally installed packages/dependencies are stored in /npm directory. Such dependencies can be used in CLI (Command Line Interface) function of any node.js but can not be imported using require() in Node application directly. To install a Node project globally use -g flag.

Source: tutorialspoint.com

Q43: What is Sass? ⭐⭐

Answer: Sass or Syntactically Awesome StyleSheets is a CSS preprocessor that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly.

A CSS preprocessor is a scripting language that extends CSS by allowing developers to write code in one language and then compile it into CSS.

Source: sass-lang.com

Q44: Describe what User Interface (UI) Design does mean for you? ⭐⭐

Answer: User Interface (UI) design is the design of software or websites with the focus on the user’s experience and interaction. The goal of user interface design is to make the user’s interaction as simple and efficient as possible. Good user interface design puts emphasis on goals and completing tasks, and good UI design never draws more attention to itself than enforcing user goals.

Source: uxplanet.org

Q45: What is SQL injection? ⭐

Answer: Injection attacks stem from a lack of strict separation between program instructions (i.e., code) and user-provided (or external) input. This allows an attacker to inject malicious code into a data snippet.

SQL injection is one of the most common types of injection attack. To carry it out, an attacker provides malicious SQL statements through the application.

How to prevent:

  • Prepared statements with parameterized queries
  • Stored procedures
  • Input validation - blacklist validation and whitelist validation
  • Principle of least privilege - Application accounts shouldn’t assign DBA or admin type access onto the database server. This ensures that if an application is compromised, an attacker won’t have the rights to the database through the compromised application.

Source: https://www.synopsys.com

Q46: What is impersonation? ⭐⭐

Answer: Impersonation is an act of pretending to be another person. For IT Systems impersonation means that some specific users (usually Admins) could get an access to other user's data.

Q47: What is Cross Site Scripting (XSS)? ⭐⭐

Answer: By using Cross Site Scripting (XSS) technique, users executed malicious scripts (also called payloads) unintentionally by clicking on untrusted links and hence, these scripts pass cookies information to attackers.

Source: allabouttesting.org

Q48: What is ClickJacking? ⭐⭐⭐

Answer: ClickJacking is an attack that fools users into thinking they are clicking on one thing when they are actually clicking on another. The attack is possible thanks to HTML frames (iframes).

Its other name, user interface (UI) redressing, better describes what is going on. Users think they are using a web page’s normal UI, but in fact there is a hidden UI in control; in other words, the UI has been redressed. When users click something they think is safe, the hidden UI performs a different action.

Source: synopsys.com

Originally published on 👉 50 Senior Java Developer Interview Questions To Ask in 2020 | FullStack.Cafe

Q1: What is Builder pattern? ⭐⭐

Answer: Builder pattern builds a complex object using simple objects and using a step by step approach. This builder is independent of other objects.

The Director class is optional and is used to make sure that the building steps are executed in the right order with the right data by the right builder. It's about validation and delegation.

Builder/Director pattern's steps invocations could be semantically presented by method chaining or so called Fluent Interface syntax.

Pizza pizza = new Pizza.Builder()
                       .cheese(true)
                       .pepperoni(true)
                       .bacon(true)
                       .build();

Source: tutorialspoint.com

Q2: What is Adapter Pattern? ⭐⭐⭐

Answer: Adapter pattern works as a bridge between two incompatible interfaces. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces (adaptees).


A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop.

Source: tutorialspoint.com

Q3: What is Facade pattern? ⭐⭐⭐

Answer: Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. This type of design pattern comes under structural pattern as this pattern adds an interface to existing system to hide its complexities.

This pattern involves a single class which provides simplified methods required by client and delegates calls to methods of existing system classes.

Source: tutorialspoint.com

Q4: What is the function of CI (Continuous Integration) server? ⭐⭐

Answer: CI server function is to continuously integrate all changes being made and committed to repository by different developers and check for compile errors. It needs to build code several times a day, preferably after every commit so it can detect which commit made the breakage if the breakage happens.

Source: linoxide.com

Q5: What are the differences between continuous integration, continuous delivery, and continuous deployment? ⭐⭐⭐

Answer:

  • Developers practicing continuous integration merge their changes back to the main branch as often as possible. By doing so, you avoid the integration hell that usually happens when people wait for release day to merge their changes into the release branch.
  • Continuous delivery is an extension of continuous integration to make sure that you can release new changes to your customers quickly in a sustainable way. This means that on top of having automated your testing, you also have automated your release process and you can deploy your application at any point of time by clicking on a button.
  • Continuous deployment goes one step further than continuous delivery. With this practice, every change that passes all stages of your production pipeline is released to your customers. There's no human intervention, and only a failed test will prevent a new change to be deployed to production.

Source: atlassian.com

Q6: What is JVM? Why is Java called the “Platform Independent Programming Language”? ⭐

Answer: A Java virtual machine (JVM) is a process virtual machine that can execute Java bytecode. Each Java source file is compiled into a bytecode file, which is executed by the JVM. Java was designed to allow application programs to be built that could be run on any platform, without having to be rewritten or recompiled by the programmer for each separate platform. A Java virtual machine makes this possible, because it is aware of the specific instruction lengths and other particularities of the underlying hardware platform.

Source: github.com/snowdream

Q7: What is the Difference between JDK and JRE? ⭐

Answer:

  • **The Java Runtime Environment (JRE) **is basically the Java Virtual Machine (JVM) where your Java programs are being executed. It also includes browser plugins for applet execution.

  • The Java Development Kit (JDK) is the full featured Software Development Kit for Java, including the JRE, the compilers and tools (like JavaDoc, and Java Debugger), in order for a user to develop, compile and execute Java applications.

Source: github.com/snowdream

Q8: What does System.gc() and Runtime.gc() methods do? ⭐⭐

Answer: These methods can be used as a hint to the JVM, in order to start a garbage collection. However, this it is up to the Java Virtual Machine (JVM) to start the garbage collection immediately or later in time.

Source: github.com/snowdream

Q9: What is JDBC? ⭐⭐

Answer: JDBC is an abstraction layer that allows users to choose between databases. [JDBC enables developers to write database applications in Java](