Monday 22 February 2021

JavaScript Interview Questions

JavaScript Interview Questions and Answers

1) What is JavaScript?

Answer:


JavaScript is a scripting language. It is different from Java language. It is object-based, lightweight and cross platform. It is widely used for client side validation.


2) What is the difference between JavaScript and jscript?

Answer:


Netscape provided the JavaScript language. Microsoft modified the name and called it JScript to avoid the trademark issue. In another words, you can say JScript is same as JavaScript, but it is provided by Microsoft.


3) How to write a hello world example of JavaScript?

Answer:


A basic example of JavaScript hello world is given below. You should place it inside the body tag of html.


<script type=”text/javascript”>


document.write(“JavaScript Hello World!”);


</script>


4) How to use external JavaScript file?

Answer:


I am assuming that js file name is samplefile.js, place the following script tag inside the head tag.


<script type=”text/javascript” src=” samplefile.js”></script>


5) Is JavaScript case sensitive language?

Answer:


Yes.


6) What is BOM?

Answer:


BOM stands for Browser Object Model. It provides interaction with the browser. The default object of browser is window. Browser Object Model


7) What is DOM? What is the use of document object?

Answer:


DOM stands for Document Object Model. A document object represents the html document. It can be accustomed to access and change the content of html of Document Object Model


8) What is the use of window object?

Answer:


The window object is automatically created by the browser that represents a window of a browser.


It is used to show the popup dialog box such as alert confirm dialog box, dialog box, input dialog box etc.


9) What is the use of history object?

Answer:


The history object of browser is accustomed switch to history pages like back and forward from current page or another page. There are three methods of history object.


history.back()


history.forward()


history.go(number): number may be positive for forward, negative for backward.


10) How to write comment in JavaScript?

Answer:


There are two types of comments in JavaScript.


Single Line Comment: It is written as // (double forward slash)


Multi Line Comment: It is written as slash with asterisk symbol as /* write comment here */


11) How to create function in JavaScript?

Answer:


To create function in JavaScript, syntax as follows.


function function_name(){


//function body


}


12) What are the JavaScript data types?

Answer:


There are two types of data types in JavaScript:


Primitive Data Types

Non-primitive Data Types

13) What is the difference between == and ===?

Answer:


The == operator checks equality only whereas === checks equality and data type i.e. value must be of same type(strict in nature).


14) How to write html code dynamically using JavaScript?

Answer:


The innerHTML property is employed to write the HTML code using JavaScript dynamically. Let’s see a sample example:


document.getElementById(‘mylocation’).innerHTML=”<h2>This is heading using JavaScript</h2>”;


15) How to write normal text code using JavaScript dynamically?

Answer:


The innerText property is empployed to write the simple text using JavaScript dynamically. Let’s see a simple Example:


document.getElementById(‘mylocation’).innerText=”This is text using JavaScript”;


16) How to create objects in JavaScript?

Answer:


There are three ways in which to form an object in JavaScript.


    By object literal

    By creating instance of Object

    By Object Constructor

Let’s see an easy code to create object using object literal.


emp={id:102,name:”Rahul Kumar”,salary:50000}


17) How to create array in JavaScript?

Answer:


There are three ways in which to form an array in JavaScript.


    By array literal

    By creating instance of Array

    By using an Array constructor

Let’s see an easy code to create array using object literal.


var emp=[“Shyam”,”Vimal”,”Ratan”];


18) What does the isNaN() function?

Answer:


The isNan() function returns true if the variable or given value is not a number.


19) What is the output of 10+20+”30″ in JavaScript?

Answer:


3030 because 10+20 will be 30. If there is numeric value before and after +, it is treated is binary + and inside double codes it is treated as string value (arithmetic operator).


20) What is the output of “10”+20+30 in JavaScript?

Answer:


Output is 102030 because after a string all the + will be treated as string concatenation operator (not binary +).


21) Difference between Client side JavaScript and Server side JavaScript?

Answer:


Client side JavaScript comprises the basic language and predefined objects that are relevant to running java script in a browser. The client side JavaScript is embedded directly by within the HTML pages. This script is understood by the browser at run time.


Server side JavaScript also resembles like client side javascript. It has relevant java script which is to be run in a server. The server sides JavaScript are deployed only after compilation.


22) In which location cookies are stored on the hard disk?

Answer:


The storage of cookies on the hard disk depends on OS and also the browser.


The Netscape navigator on Windows uses samplecookies.txt file that contains all the cookies. The path is : c:\Program Files\Netscape\Users\Username\samplecookies.txt


The Internet Explorer stores the cookies on a file uname@website.txt. The path is: c:\Windows\Cookies\uname@Website.txt.


23) What is the real name of JavaScript?

Answer:


Original name was Mocha, a name chosen by Marc Andreessen, founder of Netscape. In Sep 1995, the name was changed to LiveScript. In Dec 1995, after receiving a trademark license from Sun, the name JavaScript was adopted.


24) What is the difference between undefined value and null value?

Answer:


Undefined value is the value that is not defined and has no keyword is known as undefined value. For Example:

int number;//Here, number has undefined value.


Null value is the value that is explicitly specified by the keyword “null” is known as null value. For Example:

String str=null;//Here, str has a null value.


24) How to set the cursor to wait in JavaScript?

Answer:


Cursor can be set  in JavaScript by using “cursor” property. The following example illustrates the usage:


<script>


window.document.body.style.cursor = “wait”;


</script>


25) What is this?

Answer:


var myArray = [[[]]];


Three dimensional array.


26) Are Java and JavaScript same?

Answer:


No, Java and JavaScript are the both are different languages. JavaScript is a client side scripting language with some limitations whereas Java is a robust, secured and object-oriented programming language.


27) What is negative infinity?

Answer:


Negative Infinity is a number in JavaScript which can be derived by dividing negative number by 0.


28) What is difference between View state and Session state?

Answer:


“View state” is restricted to a page in a session whereas “Session state” is specific to a user or browser which will be accessed across all pages in the web application.


29) What are the pop up boxes available in JavaScript?

Answer:


    Alert Box

    Confirm Box

    Prompt Box

30) How can we detect OS of the client machine using JavaScript?

Answer:


The navigator.appVersion string can be used to detect the operating system on the client machine.


31) How to submit a form using JavaScript by clicking a link?

Answer:


Let’s see the JavaScript code to submit form on clicking the link.


<form name=”myform” action=”index.php”>


Search: <input type=’text’ name=’query’ />


<a href=”javascript: submitform()”>Search</a>


</form>


<script type=”text/javascript”>


function submitform()


{


document.myform.submit();


}


</script>


32) Is JavaScript faster than ASP script?

Answer:


Yes, as a result of it doesn’t require web server’s support for execution.


33) How to change the background color of HTML document using JavaScript?

Answer:


<script type=”text/javascript”>


document.body.bgColor=”pink”;


</script>


34) How to handle exceptions in JavaScript?

Answer:


By the help of try/catch block, we are able to handle exceptions in JavaScript. JavaScript supports try, catch, finally and throw keywords for exception handling. 

Saturday 20 February 2021

Multiple Choice Questions and Answers on Optical Fiber Communication(Part-2)

1)   The macroscopic bending losses show an exponential increase due to ________ in radius of curvature.

a. Increase

b. Decrease

c. Stability

d. None of the above


ANSWER: (b) Decrease


2)   Which type of mechanical splicing exhibits the permanent bonding of prepared fiber ends with the rigid alignment of the tube?

a. Snug Tube Splicing

b. Loose Tube Splicing

c. Elastomeric Splicing

d. Precision Pin Splicing


ANSWER: (a) Snug Tube Splicing


3)   Which component of fiber-optic connector has a provision of entry for the fiber along with the fixation to connector housing?

a. Ferrule

b. Cable

c. Connector Housing

d. Coupling Device


ANSWER: (b) Cable


4)   Which among the following is regarded as a keyed bayonet connector along with its feasibility of easiest insertion and removal from the fiber optic cable?

a. FC Connectors

b. LC Connectors

c. MT-RJ Connectors

d. ST Connectors


ANSWER: (d) ST Connectors


5)   How many mating cycles are being rated by typically matched SC Connectors?

a. 500

b. 600

c. 800

d. 1000


ANSWER: (d) 1000


6)   In Stimulated Emission, which among the following parameters of generated photon is/are similar to the photon of incident wave?

a. Phase

b. Frequency

c. Polarization & direction of travel

d. All of the above


ANSWER: (d) All of the above


7)   Consider a crystal of ruby laser whose length is 6 cm and the refractive index is 1.8, emits the wavelength of about 0.55 μm. What will be the value of number of longitudinal modes?

a. 3.9 x 105

b. 4.9 x 105

c. 5.6 x 105

d. 7.7 x 105


ANSWER: (a) 3.9 x 105


8)   In a laser structure, the existence of standing waves is possible at frequencies for which the distance between the mirrors is an integral number of ________

a. λ / 2

b. λ / 4

c. λ / 6

d. λ / 8


ANSWER: (a) λ / 2


9)   The small section of fiber which is coupled to the optical source is known as _________

a. Flylead

b. Pigtail

c. Both a and b

d. None of the above


ANSWER: (c) Both a and b


10)   In Lambertian output pattern of LED, the source is ______ bright from all directions.

a. Less

b. Equally

c. More

d. Unpredictably


ANSWER: (b) Equally


11)   In pyroelectric photodetectors, the consequent increase in dielectric constant due to temperature variation by the photon absorption, is generally measured as change in _______

a. resistance

b. inductance

c. admittance

d. capacitance


ANSWER: (d) capacitance


12)   Which type of preamplifier plays a crucial role in reducing the effect of thermal noise?

a. Low Impedance Pre-amplifier

b. High Impedance Preamplifier

c. Transimpedance Preamplifier

d. None of the above


ANSWER: (b) High Impedance Preamplifier


13)   In high impedance preamplifier, how are the noise sources kept to minimum level?

a. By reducing dark current with proper selection of photodiode

b. By reducing thermal noise of biasing resistor

c. By using high impedance amplifier

d. All of the above


ANSWER: (d) All of the above


14)   Which among the following are the disadvantages of an optical feedback transimpedance receiver?

A. Increase in receiver input capacitance

B. Increase in dark current

C. Decrease in receiver input capacitance

D. Decrease in dark current


a. A & B

b. C & D

c. A & D

d. B & C


ANSWER: (a) A & B


15)   Which category/ies of wavelength division multiplexer comprise/s two 3dB couplers where the splitting of an incident beam takes place into two fiber paths, followed by the recombination with second 3-dB coupler?

a. Interference filter based devices

b. Angular dispersion based devices

c. Mach-Zehnder Interferometers

d. All of the above


ANSWER: (c) Mach-Zehnder Interferometers


16)   Which among the following controls the length of Fabry-Perot interferometer so that it can act as a tunable optical filter?

a. Transducer

b. Tachometer

c. Multimeter

d. Phase-meter


ANSWER: (a) Transducer


17)   In circulator, an optical path of signal follows _______

a. An open loop

b. A closed loop

c. Both a and b

d. None of the above


ANSWER: (b) A closed loop


18)   Which among the following is/are responsible for generating attenuation of an optical power in fiber?

a. Absorption

b. Scattering

c. Waveguide effect

d. All of the above


ANSWER: (d) All of the above


19)   Consider the assertions/ characteristics given below. Which type of attenuation measurement technique exhibits these characteristics?

1. Necessity of accessing both ends of fiber.

2. Measurements corresponding to specific wavelengths.

3. Requirement of spectral response over a range of wavelengths.



 

a. Cutback Technique

b. Insertion Loss Technique

c. Use of OTDR Technique

d. None of the above


ANSWER: (a) Cutback Technique


20)   For neglecting the pulse dispersion in the digital systems, the rms width of fiber impulse response must be _________one-quarter of the pulse spacing.

a. Less than

b. Equal to

c. Greater than

d. None of the above


ANSWER: (a) Less than


21)   If a noisy channel has a bandwidth of 4 MHz with signal to noise ratio of about 1, what would be the maximum capacity of the channel?

a. 2 Mb/sec

b. 4 Mb/sec

c. 6 Mb/sec

d. 8 Mb/sec


ANSWER: (b) 4 Mb/sec


22)   In the structure of fiber optic cable, the refractive index of core is always _______the refractive index of cladding.

a. Less than

b. Equal to

c. Greater than

d. None of the above


ANSWER: (c) Greater than


23)   The order of mode is equal to the number of field____ across the guide.

a. Zeros

b. Poles

c. Ones

d. All of the above


ANSWER: (a) Zeros


24)   Which among the following represents the lateral shift of a light beam on reflection at a dielectric interface?

 a. Doppler’s Shift

b. Goos-Haenchen’s Shift

c. Frequency Shift

d. Phase Shift

ANSWER: (b) Goos-Haenchen’s Shift


25)   Why are plastic clad silica fiber optic cables not used widely?

a. Difficulty in connector application due to excessive plasticity in cladding

b. Difficulty in bonding

c. Insolubility in organic solvents

d. All of the above


ANSWER: (d) All of the above


26)   In cables, water is prevented from filling the spaces with __________resistant compounds.

a. moisture

b. pressure

c. temperature

d. stress


ANSWER: (a) moisture


27)   Which reason/s is/are responsible for the occurrence of non-linear Cross Phase Modulation (XPM)?

a. Difference in transmission phase of peak pulse & leading or trailing edges of pulse

b. Third-order optical non-linearity

c. Intensity dependence of refractive index

d. All of the above


ANSWER: (c) Intensity dependence of refractive index



 

28)   What is/ are the consequence/s of Self Phase Modulation in non-linear optics? 

a. Modification in pulse spectrum

b. Limited transmission rate

c. Dispersion effect

d. All of the above


ANSWER: (d) All of the above


29)   Which type of fiber-optic coupler causes the distribution of an optical power from more than two input ports among the several output ports?

 a. Star Coupler

b. Tree Coupler

c. X Coupler

d. All of the above

ANSWER: (a) Star Coupler


30)   Which optical devices are adopted or applicable for routing signals from one waveguide to another?

a. Optical Combiner

b. Optical Splitter

c. Optical Coupler

d. None of the above


ANSWER: (c) Optical Coupler


31)   Which among the following characteristics of Laser light specifies the precise movement of all individual light waves together through time and space?

 a. Monochromatic

b. Directional

c. Coherent

d. Brightness

ANSWER: (c) Coherent


32)   Which modes are acknowledged due to their association with electromagnetic field and beam profile in the direction perpendicular to the plane of pn junction?

a. Longitudinal Modes

b. Transverse Modes

c. Lateral Modes

d. All of the above


ANSWER: (b) Transverse Modes


33)   Which type of injection laser involves the use of geometry for fabrication of the multimode injection laser with a single or small number of lateral modes?

a. Gain guided laser

b. Index guided laser

c. Quantum well laser

d. Quantum dot laser


ANSWER: (a) Gain guided laser


34)   In the dynamic response of Injection Laser Diode (ILD), the delay which is followed by ____ frequency damped oscillations give rise to the generation of relaxation oscillations.

a. Low

b. Medium

c. High

d. All of the above


ANSWER: (c) High


35)   The spectral response of an ideal photodetector depicts its efficiency as a function of _________

a. amplitude

b. frequency

c. period

d. wavelength


ANSWER: (d) wavelength


36)   According to frequency response of photo-detector, the modulation frequency at which the output current decreases to ________of peak value.

a. one-third

b. one-fourth

c. half

d. one-tenth


ANSWER: (c) half


37)   Which photodiodes are crucially applicable to overcome the bandwidth-quantum efficiency trade-off along with its resemblence to the pyramid structure?

a. Mushroom Waveguide Photodiode

b. Traveling Wave Photodiode

c. Resonant Cavity Photodiode

d. All of the above


ANSWER: (a) Mushroom Waveguide Photodiode


38)   When an optical signal is incident on a photo-detector, which noise originate/s due to statistical nature of production and collection of photoelectrons?

a. Dark Current Noise

b. Quantum Noise

c. Surface Leakage Current noise

d. All of the above


ANSWER: (b) Quantum Noise


39)   In an eye-diagram, digital signals with very bad interference resembles the shape of _____

a. circle

b. rectangle

c. triangle

d. straight line


ANSWER:(d)  straight line


40)   On which factor/s do/does the response time of photodiode depend/s?

a. Diffusion time of photo carriers outside the depletion region

b. Diffusion time of photo carriers within the depletion region

c. RC time constant

d. All of the above


ANSWER: (d) All of the above


41)   Which nature of charge carriers give rise to the current fluctuations thereby resulting into the generation of shot noise?

a. Continuous

b. Discrete

c. Sampled

d. All of the above


ANSWER: (b) Discrete


42)   Which among the following parameters is/are decided by the front-end of a receiver?

a. Sensitivity

b. Bandwidth

c. Both a and b

d. None of the above


ANSWER: (c) Both a and b


43)   In an optical network, increase in the number of lasers ________the bit rate.

a. Increases

b. Stabilizes

c. Decreases

d. None of the above


ANSWER: (a) Increases


44)   Which band/s specify/ies the operation range of Erbium doped fiber amplifier (EDFA)?

a. By O band

b. By C band

c. By S band

d. All of the above


ANSWER: (b) By C band


45)   Basically, solitons are pulses which propagates through the fiber without showing any variation in ______

a. Amplitude

b. Velocity

c. Shape

d. All of the above


ANSWER: (d) All of the above


46)   Why is an electrical isolation required between several portions of an electronic circuit?

a. Provision of high voltage protection

b. Reduction in noise level

c. Both a & b

d. None of the above


ANSWER: (c) Both a & b


47)   For measuring the shape of input pulse in time-domain intermodal dispersion method, the test fiber is replaced by another fiber whose length is less than ___ of the test fiber.

a. 1%

b. 5%

c. 10%

d. 20%


ANSWER: (a) 1%


48)   In chromatic dispersion, which parameter for the modulation of the received signal is measured with the help of a vector voltmeter?

a. Amplitude

b. Frequency

c. Phase

d. Period


ANSWER: (c) Phase


49)   Which among the following stages is/are adopted in Splice Loss Experiment?

a. Translational

b. Rotational

c. Both a and b

d. None of the above


ANSWER: (c) Both a and b


50)   Which among the following misalignments give/gives rise to the occurrence of splice loss?

a. Longitudinal separation between the end-faces of fiber

b. Angular tilt between fiber ends

c. Transverse offset between fiber ends

d. All of the above


ANSWER: (d) All of the above

MCQ Question Bank Microsoft PowerPoint