0% found this document useful (0 votes)
81 views10 pages

Procom Interview Questions

The document provides answers to interview questions about JavaScript, Object Oriented Programming (OOP), and React. It contains 14 questions about JavaScript fundamentals, OOP concepts, and React lifecycles and components. Key topics covered include data types, exceptions, functions, classes, objects, inheritance, polymorphism, encapsulation, React phases, pure components, and higher order components.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views10 pages

Procom Interview Questions

The document provides answers to interview questions about JavaScript, Object Oriented Programming (OOP), and React. It contains 14 questions about JavaScript fundamentals, OOP concepts, and React lifecycles and components. Key topics covered include data types, exceptions, functions, classes, objects, inheritance, polymorphism, encapsulation, React phases, pure components, and higher order components.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 10

Procom Interview

Questions
JavaScript:
Question 1: What is the answer of true === "true" in java script?
Answer 1: The expression true === "true" in JavaScript will return false.
Reasoning: This is because true is a boolean primitive value, whereas "true" is a string primitive value.
The === operator in JavaScript checks for both value and type equality, so since true and "true" are of
different types, the answer is false.

Question 2: What would be the result of 3+2+”7″?


Answer 2: Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its
concatenation will be done. So the result would be 57.

Question 3: What is break and continue statements?


Answer 3: Break statement exits from the current loop. Continue statement continues with next statement
of the loop.

Question 4. What are the two basic groups of data types in JavaScript?
Answer 4:
• They are as—Primitive
• Reference types

Primitive types are number and Boolean data types. Reference types are more complex types like strings
and dates.

Question 5. Which keywords are used to handle exceptions?


Answer 5:
Try… Catch—finally is used to handle exceptions in the JavaScript
Try{
Code
}
Catch(exp){
Code to throw an exception.
}
Finally{
Code runs either it finishes successfully or after catch
}
Question 6: Differentiate between runtime, load-time errors and logical errors.
Answer 6:
Load-time errors: The errors shown at the time of the page loading are counted under Load-time errors.
The use of improper syntax encounters these errors and is thus detected while the page is getting loaded.
Runtime errors: This is the error that comes up while the program is running. For example, illegal
operations cause the division of a number by zero or access a non-existent area of the memory.
Logic errors: It is caused by syntactically correct code, which does not fulfill the required task—for
example, an infinite loop.

Question 7: What does the following statement declare?


var myArray = [[[]]];

Answer 7: It declares a three-dimensional array.

Question 8: What will the code below output? Explain your answer.
console.log(0.1 + 0.2);
console.log(0.1 + 0.2 == 0.3)
Answer 8: An educated answer to this question would simply be: “You can’t be sure. it might print out
0.3 and true, or it might not. Numbers in JavaScript are all treated with floating point precision, and as
such, may not always yield the expected results.”
The example provided above is classic case that demonstrates this issue. Surprisingly, it will print out:
0.30000000000000004
false

Question 9: Define Anonymous Function?


Answer 9:
It is a function that has no name. These functions are declared dynamically at runtime using the function
operator instead of the function declaration. example:

var display=function(){
alert("Anonymous Function is invoked");
}

Question 10: What are arrow function in JavaScript?


Answer 10: In JavaScript, arrow functions are a shorthand syntax for defining functions.
const sum = (a, b) => a + b;

In this example, the arrow function sum takes two parameters a and b, and returns their sum using the +
operator.

const square = (x) => {


const result = x * x;
return result;
};

Object Oriented Programming:

Question 1: Write basic concepts of OOPS?


Answer 1:
Following are the concepts of OOPS:

Abstraction, Encapsulation, Inheritance, Polymorphism

Question 2: What is a class?


Answer 2: A class is simply a representation of a type of object. It is the blueprint/plan/template that
describes the details of an object.

Question 3: What is an Object?


Answer 3: An object is an instance of a class. It has its own state, behavior, and identity.

Question 4. What is Encapsulation?


Answer 4: Encapsulation is an attribute of an object, and it contains all data which is hidden. That hidden
data can be restricted to the members of that class.
Levels are Public, Protected, Private, Internal, and Protected Internal.

Question 5. What is Polymorphism?


Answer 5: Polymorphism is nothing but assigning behavior or value in a subclass to something that was
already declared in the main class. Simply, polymorphism takes more than one form.
Question 6: What is Inheritance?
Answer 6: Inheritance is a concept where one class shares the structure and behavior defined in another
class. If Inheritance applied to one class is called Single Inheritance, and if it depends on multiple classes,
then it is called multiple Inheritance.

Question 7: Define Destructor?


Answer 7: A destructor is a method which is automatically called when the object is made of scope or
destroyed. Destructor name is also same as class name but with the tilde symbol before the name.

Question 8: What is a virtual function?


Answer 8: A virtual function is a member function of a class, and its functionality can be overridden in
its derived class. This function can be implemented by using a keyword called virtual, and it can be given
during function declaration.
A virtual function can be declared using a token(virtual) in C++. It can be achieved in C/Python
Language by using function pointers or pointers to function.

Question 9: What is a friend function?


Answer 9: A friend function is a friend of a class that is allowed to access to Public, private, or protected
data in that same class. If the function is defined outside the class cannot access such information.
A friend can be declared anywhere in the class declaration, and it cannot be affected by access control
keywords like private, public, or protected.

Question 10: What is function overloading?


Answer 10: Function overloading is a regular function, but it is assigned with multiple parameters. It
allows the creation of several methods with the same name which differ from each other by the type of
input and output of the function.

Question 11: What is operator overloading?


Answer 11: Operator overloading is a programming concept that allows operators to be redefined for
custom data types or classes, beyond their default behavior. In other words, it allows a programmer to
define how an operator works with custom types and objects.
class MyClass:
def __init__(self, x):
self.x = x
def __add__(self, other):
return MyClass(self.x + other.x)

a = MyClass(3)
b = MyClass(4)
c = a + b # returns a new instance of MyClass with x=7

Question 12: What is an abstract class?


Answer 12: An abstract class is a class which cannot be instantiated. Creation of an object is not
possible with an abstract class, but it can be inherited. An abstract class can contain only an
Abstract method. Java allows only abstract method in abstract class while other languages allow
non-abstract method as well.

Question 13: What is a ternary operator?


Answer 13: The ternary operator is said to be an operator which takes three arguments. Arguments and
results are of different data types, and it depends on the function. The ternary operator is also called a
conditional operator.

Question 14: What is the main difference between a class and an object?
Answer 14: An object is an instance of a class. Objects hold multiple information, but classes don’t have
any information. Definition of properties and functions can be done in class and can be used by the
object.
A class can have sub-classes, while an object doesn’t have sub-objects.

React:

Question 1: What are the different phases of React component's lifecycle?


Answer 1:
The different phases of React component's life cycle are:
Initial Phase: It is the birth phase of the React life cycle when the component starts its journey on a way to
the DOM. In this phase, a component contains the default Props and initial State. These default properties
are done in the constructor of a component.
Mounting Phase: In this phase, the instance of a component is created and added into the DOM.
Updating Phase: It is the next phase of the React life cycle. In this phase, we get new Props and change
State. This phase can potentially update and re-render only when a prop or state change occurs. The main
aim of this phase is to ensure that the component is displaying the latest version of itself. This phase
repeats again and again.
Unmounting Phase: It is the final phase of the React life cycle, where the component instance is destroyed
and unmounted(removed) from the DOM.

Question 2: What are Pure Components?


Answer 2: Pure components introduced in React 15.3 version. The React. Component and
React.PureComponent differ in the shouldComponentUpdate() React life cycle method. This method
decides the re-rendering of the component by returning a boolean value (true or false). In React.
Component, shouldComponentUpdate() method returns true by default. But in React.PureComponent, it
compares the changes in state or props to re-render the component. The pure component enhances the
simplicity of the code and performance of the application.

Question 3: What are Higher Order Components(HOC)?


Answer 3: In React, Higher Order Component is an advanced technique for reusing component logic. It is
a function that takes a component and returns a new component. In other words, it is a function which
accepts another function as an argument. According to the official website, it is not the feature(part) in
React API, but a pattern that emerges from Reacts compositional nature.

Question 4: What can you do with HOC?


Answer 4:
Code Re usability
Props manipulation
State manipulation
Render hijacking

Question 5: What are 2 ways to create a component in React?


Answer 5:
Function Components: This is the simplest way to create a component in React. These are the pure
JavaScript functions that accept props object as the first parameter and return React elements:
function Greeting({ message }) {
return <h1>{`Hello, ${message}`}</h1>
}

Class Components: The class components method facilitates you to use ES6 class to define a
component. The above function component can be written as:
class Greeting extends React.Component {
render() {
return <h1>{`Hello, ${this.props.message}`}</h1>
}
}

Question 6: Define UseContext?


Answer 6: Know the answer.

Laravel:

Question 1: What does MVC stand for.

Answer 1: Model View Controller.

Question 2: Define MVC.

Answer 2: Know the answer.

Question 3: Define composer.

Answer 3: It is an application-level package manager for PHP. It provides a standard format for managing
PHP software dependencies and libraries.
Question 4: Define laravel query builder.

Answer 4: Laravel query builder is a feature of the Laravel PHP framework that provides a simple and
convenient way to build and execute database queries using a fluent, chain-able interface.

Question 5: What is a Controller.

Answer 5: In Laravel, a controller is a PHP class that handles HTTP requests and returns HTTP
responses. Controllers are responsible for handling user input, interacting with models and services, and
returning appropriate responses to the client.

Question 6: What is a Trait?


Answer 6: Laravel traits are a group of functions that you include within another class. A trait is like an
abstract class. You cannot instantiate directly, but its methods can be used in concreate class.

Question 7: Name the Template Engine utilized by Laravel.

Answer 7: Blade is a powerful template engine utilized by Laravel.

Question 8: Why are migrations important?

Answer 8: Migrations are important because it allows you to share application by maintaining database
consistency. Without migration, it is difficult to share any Laravel application. It also allows you to sync
database.

Question 9: Explain Collections in Laravel.


Answer 9: Collections is a wrapper class to work with arrays. Laravel Eloquent queries use a set of the
most common functions to return database result.

Question 10: What are Observers?


Answer 10: Model Observers is a feature of Laravel. It is used to make clusters of event listeners for a
model. Method names of these classes depict the Eloquent event. Observers classes methods receive the
model as an argument.

You might also like