DHTML and Javascript

Here are the top interview questions for DHTML and JavaScript Developer, the questions are submitted by professionals to help you to ace the job interview.

Q.1 Differentiate between Static and Dynamic Html.
Firstly, static HTML once displayed cannot be changed on the other hand dynamic HTML can be changed. Secondly, Static web pages cannot have database access but dynamic pages can be connected to the database. Thirdly, Static HTML does not require server-side coding but dynamic HTML requires server-side coding. Lastly, in static HTML no animation or games can be developed but dynamic HTML can perform this task.
Q.2 How can we control the events with DHTML?
A DHTML application supports numerous events out of which many of them are quite analogous to those of a standard VB application. For handling events in DHTML, we attach an event handler to HTML elements. The event handler waits until a certain event, for instance, a click on a link, takes place. After this, it handles the event by executing some JavaScript code that has been defined by us. Then, after the execution of the code, the event handlers come to their initial state and wait for the user to fire any event. Lastly, to handle events in DHTML we need to register an event handler.
Q.3 What is the process for uploading struts files in DHTML?
The interface org.apache.struts.upload.FormFile is used for the struts file upload application. This interface represents a file that has been uploaded by a client. It is the only interface or class in the upload package which is typically referenced directly by a Struts application.
Q.4 How to create a DHTML drop-down menu?
For creating a DHTML drop-down menu we need JavaScript API. The API (Application Programming Interface) contains a core set of cross-browser JavaScript functions to make DHTML programming easy and quick. This API allows moving and hiding page elements as well as acts as getter and setter of page elements attributes. After that, we specify the image object and off-image object and string containing the URL of the "off" version. Thirdly, we build the menu items, label items, and sub-menu items. Next, it is required to define our own global variables that will be used by the menu. Then, create the menubar object, adding the menu labels and writing menubars. Now, create menu objects, adding menu items, and writing menus. Lastly, hiding and displaying the menus and attaching stylesheets.
Q.5 Define XHTML.
XHTML stands for Extensible Hypertext Markup Language that refers to a cross between HTML and XML. It helps us to create better-formatted code for the site by making it more accessible. The XHTML has more strict syntax rules in comparison to HTML and gives a more consistent, well-structured format. Further, it makes the website easier to maintain, edit, convert and format in the long run.
Q.6 What are the features of JavaScript?
Some of the features of JavaScript are: Lightweight Complementary to HTML Interpreted programming language Good for the applications which are network-centric Complementary to Java Open-source Cross-platform
Q.7 What is an anonymous function?
This refers to a function that has no name. These functions are declared dynamically at runtime using the function operator rather than the function declaration. The function operator is more flexible than a function declaration. It can be easily used in the place of an expression. For example: var display=function() { alert("Anonymous Function is invoked"); } display();
Q.8 What do you understand by the term closure?
In JavaScript, we require closures when a variable that is defined outside the scope in reference is accessed from some inner scope.
Q.9 Which method is used for returning the character from a specific index?
The JavaScript string charAt() method is used for finding out a char value present at the specified index. The index number starts from 0 and goes to n-1, where n is the length of the string. The index value can't be a negative, greater than, or equal to the length of the string. For example: var str="Javatpoint"; document.writeln(str.charAt(4));
Q.10 Is there any difference between JavaScript and JScript?
Netscape provided the JavaScript language. Microsoft changed the name and called it JScript for avoiding the trademark issue. In other words, you can say JScript is the same as JavaScript, but Microsoft provides it.
Q.11 Define the term BOM.
BOM stands for Browser Object Model that is used for providing interaction with the browser. The default object of a browser is a window. So, you can call all the functions of the window by defining the window or directly. Further, the window object provides various properties like document, history, screen, navigator, location, innerHeight, innerWidth, etc.
Q.12 What is a history object?
The history object of a browser can be used for switching to history pages such as back and forward from the current page or another page. There are three methods of history object. Firstly, history.back() for loading the previous page. Secondly, history.forward() for loading the next page. Lastly, history.go(number). In this, the number may be positive for forward, negative for backward. It is for loading the given page number.
Q.13 What are the ways for writing a comment in JavaScript?
In JavaScript, there are two ways to write a comment: 1. Single Line Comment It is represented by // (double forward slash) 2. Multi-Line Comment Slash represents it with asterisk symbol as /* write a comment here */
Q.14 Name the different data types available in JavaScript.
There are two types of data types in JavaScript: Primitive data types Non- Primitive data types
Q.15 Define Primitive data types.
The primitive data types are: 1. String The string data type represents a sequence of characters. It is written within quotes and can be represented using a single or a double quote. 2. Number This data type is used for representing numeric values and can be 3. Boolean The Boolean data type is used for representing a Boolean value, either false or true. This data type is generally used for conditional testing. 4. BigInt The BigInt data type is used for storing numbers beyond the Number data type limitation. This data type can store large integers and is represented by adding "n" to an integer literal. 5. Undefined This data type is used when a variable is declared but not allocated. 6. Null The Null data type is used for representing a non-existent, null, or invalid value that is no value at all. 7. Symbol The symbol is a new data type introduced in the ES6 version of JavaScript. It is used for storing an anonymous and unique value.
Q.16 Define non-primitive data types.
We know that primitive data types can store only a single value. However, for storing multiple and complex values, we have to use non-primitive data types. The non-primitive data types are: 1. Object The Object is a non-primitive data type that is used for storing collections of data. An object contains properties, defined as a key-value pair. A property key (name) is always a string, but the value can be any data type, such as strings, numbers, Booleans, or complex data types like arrays, functions, and other objects. 2. Array The Array data type is used for representing a group of similar values. Every value in an array has a numeric position, called its index, and it may contain data of any data type-numbers, strings, Booleans, functions, objects, and even other arrays. The array index starts from 0 so that the first array element is arr[0], not arr[1].
Q.17 Differentiate between == and ===.
The == operator checks equality only whereas === checks equality, and data type, i.e., a value must be of the same type.
Q.18 Define Client-side JavaScript and Server-side JavaScript.
Client-side JavaScript contains the basic language and predefined objects which are relevant to running JavaScript in a browser. The client-side JavaScript is embedded directly in the HTML pages. The browser interprets this script at runtime. On the other hand, server-side JavaScript also resembles client-side JavaScript. It has relevant JavaScript which is to run on a server. The server-side JavaScript is deployed only after compilation.
Q.19 I want to check if the event.preventDefault() method was used in an element or not. How will I check?
When the event.defaultPrevent() method is used in the event object, it returns a Boolean indicating that the event.preventDefault() was called in a particular element.
Q.20 Is there any requirement for debugging in JavaScript?
JavaScript does not display any error message in a browser. However, these mistakes can affect the output. The best practice to find out the error is to debug the code. The code can be debugged easily by using web browsers like Google Chrome, Mozilla Firefox. However, for performing debugging, the following approaches can be used: Firstly, using console.log() method Secondly, using debugger keyword
Q.21 What is the strict mode in JavaScript?
The JavaScript strict mode is used for generating silent errors. It provides a "use strict"; expression to allow the strict mode. This expression can only be placed as the first statement in a script or a function. For example: "use strict"; x=10; console.log(x);
Q.22 Define Math objects in JavaScript.
The JavaScript math object provides many constants and methods for performing a mathematical operation. Unlike date objects, it doesn't have constructors. For example: function display() { document.writeln(Math.random()); } display();
Q.23 Define a TypedArray object in JavaScript.
The JavaScript TypedArray object demonstrates an array like a view of an underlying binary data buffer. There can be any number of different global properties, whose values are TypedArray constructors for specific element types. function display() { var arr1= [1,2,3,4,5,6,7,8,9,10]; arr1.copyWithin(2) ; document.write(arr1); } display();
Q.24 What is hoisting in JavaScript?
Hoisting can be defined as the default behavior of JavaScript in which all the variable and function declarations are moved on top. In short, Hoisting is a process in which, irrespective of where the variables and functions are declared, they are moved on top of the scope. However, the scope can be both local and global.
Q.25 Explain the term CSS.
CSS stands for Cascading Style Sheet that is used for the presentation part of the web page. The look & feel of the page is completely based on CSS. However, in DHTML, CSS rules can be modified at both the document and the element level using JavaScript with event handlers, they can add a significant amount of dynamism with very little code.
Q.26 What is a DOM?
DOM stands for Dynamic Object Model that defines the object and its properties. It is a standard way of accessing and manipulating static content. The Document Object Model is a platform and language-neutral interface that enables programs and scripts to dynamically access the content and update it.
Q.27 What are the methods for handling exceptions in JavaScript?
Using the try/catch block, we can handle exceptions in JavaScript. JavaScript supports try, catch, finally and throw keywords for exception handling.
Q.28 In JavaScript, how can we identify the operating system of the client machine?
The navigator.appVersion string can be used for identifying the operating system on the client machine.
Q.29 Define negative infinity.
Negative Infinity refers to a number in JavaScript that can be derived by dividing the negative number by zero. For example: var num=-5; function display() { document.writeln(num/0); } display(); //expected output: -Infinity
Q.30 How to create a function in JavaScript?
For creating a function in JavaScript, use the syntax: function function_name(){ //function body }
Q.31 What happens if three p tags are in a row?
If three p tags are in a row then the browser uses only the first tag and ignores the others.
Q.32 You created an unordered list with four list items. All the content following the fourth list item that should be normal text is indented under the list. What is the most likely cause of this problem?
The most likely cause of this problem is a missing closing tag.
Q.33 What does the following CSS selection indicates -- "p.top a { color: red; }"
Links to appear red in paragraphs having class named top
Q.34 What do you understand by Javascript?
JavaScript has been defined as a general-purpose programming language designed to allow programmers to control the behavior of software objects. Javascript language has been used widely in Web browsers whose software objects tend to represent a variety of HTML elements in a document and the document itself. Javascript language is used with other kinds of objects in other environments. Therefore it is important to distinguish JavaScript, the language, from the objects it can communicate with in any particular environment. Javascript when used for Web documentation, the scripts go directly inside the HTML documents and are downloaded to the browser with the rest of the HTML tags and content.
Q.35 Which technologies are used in DHTML and describe their significance in DHTML application?
There is nothing dynamic in DHTML yet enclosing technologies like CSS, JavaScript, DOM and the static markup language it becomes dynamic.
1. JavaScript : JavaScript referred as Jscript, or ECMA Script, one of the most common language used today for client-side scripting. The primary reason for this JavaScript comes with virtually every browser. For instance an onload event could execute a JavaScript function to query the browser’s cookies collection to determine whether the user is a first-time visitor to the page.
2. CSS : CSS stands for Cascading Style Sheet which is used for the presentation part of the web page. It holds the designing of the page such that the primary look and feel of the page depends on CSS. In DHTML CSS rules can be modified at both the document and the element level using JavaScript with event handlers, such that they can add a significant amount of dynamism with very little code.
3. DOM : DOM stands for Dynamic Object Model is the weakest link in DHTML as many of the browser does not support the DOM functionality. DOM defines the object and its properties as a standard way of accessing and manipulating the static content. The DOM Model is a platform and language-neutral interface that permits program and scripts to dynamically access the content and update it.
Q.36 According to you, which browsers support DHTML and how does non-supporting browsers handle DHTML?
DTML is supported by Version of Netscape Navigator and Internet Explorer higher than 4.0 in the most convenient manner. As compared to both browsers Internet Explorer 4.0+ supports the DHTML in the best way. DHTML includes JavaScript to build the page dynamic and irrespective of which scripts is written for and the scripts are designed in such a way that it can be compatible with as many numbers of browsers as possible. One of the most crucial thing which must be kept in the mind is that we must test the code before running it over the server or making it live. Indeed we cannot guarantee that all users will use the browser that will support the scripts.
Q.37 Differentiate between DHTMLand HTML?
Some of the points of difference between DHTMLand HTML -
1. Difference between DHTML and HTML is that HTML is a markup language but DHTML is not a language.
2. DHTML stands with combination of HTML, CSS, JavaScript and DOM but HTML alone is an enough although static.
3. HTML cannot have nay server side code but DHTML may contain server side code also.
4. In HTML there is no need for database connectivity but DHTML may require to connect to database as it interacts with user.
Q.38 What are the important components of dynamic HTML authoring?
Some of the important components of dynamic HTML authoring are - 2. Relative Positioning - It is relative positioning which is somewhat same as current HTML3 layout and is considered as best reserved for situations where you want to be sure that the content will revert to this default inside a document that also uses absolute positioning.
3. Absolute Positioning - DHTML is an absolute positioning which refers to that the object will remain at the same position irrespective of the condition of other elements and the size of the browser.
4. Style Modifications - This indicates the changes in the presentation or the view part that are being made in web page. This part comes under Cascading Style Sheet where the user style his web page by using the attributes and the tags that are pre-defined in CSS.
5. Event Handling - It is explained earlier events is the beating heart of any JavaScript application. In order to handling event in DHTML we attach event handler to HTML elements. Such that the event handler waits until a certain event, for instance a click on a link, takes place. Such that when event handling happens it handles the event by executing some JavaScript code that has been defined by us. Also after it has executed the code the event handler comes to its initial state and waits for the user to fire any event.
Q.39 According to you what is the necessity of 'Empty Tag'?
The first thing to notice with reference empty tag is that they need not to be closed. The necessity of empty tags play a crucial role in development of web pages as we can create links define input tags that include button, text, hidden fields which provide links to images and line breaks. For instance the
tag is an empty tag used to draw a horizontal line on the page.
Q.40 What do you understand by Struts Dispatch Action in DHTML?
Dispatch Action is a defined as an action which comes with Struts 1.1 or later, that helps to combine Struts actions into single class, each with their own method. The org.apache.struts.action.DispatchAction class permits multiple operations to map to the different functions in the same Action class.
Q.41 What are the steps used to create a tiles application in DHTML?
Some of the steps used to create a tiles application in DHTML are -
1. To create a template that designs a layout for your application.
2. To create the composing pages.
3. To create a definition which means that suppose that you configured Tiles, in web.xml, to startup using the TilesServlet, we need to specify which files will contain the Tiles definitions to load.
4. To render the definition.
Q.42 How do you define Logic Match Tag?
Logic match tag can be defined as an evaluator that assesses the nested body content of tag to check whether the specified value is an appropriate substring of the requested variable. It is required to match the variable specified by one of the selector attributes against the specified constant value. Therefore if the value is a substring the nested body content of this tag is thereby evaluated.
Q.43 Differentiate between DHTML and HTML?
Some of the difference between DHTML (Dynamic HTML) and HTML (Hyper Text Markup Language) are -
1. Using DHTML we can use JavaScript and style sheets in our HTML page.
2. Using DHTML we can insert small animations and dynamic menus into our HTML page.
3. If use want that your web page display your DHTML effects (such that object or word can highlighted, larger, different color) such that then you have to save your web page with .dhtml extension except .html or .htm
Q.44 What is the primary difference between FontSize and Font Size, in DHTML?
The primary point of difference between is that “FontSize” is a property, such that “Font Size” is a style in DHTML.
Q.45 What are the attributes that make up a DHTML?
DHTML abbreviated as Dynamic HTML which is used to increase the interactive ability and the visual effect of the web pages that is loaded in the browser. The primary technologies used in DHTML are namely - HTML, JavaScript and CSS also referred as Cascading Style Sheet. The DOM also referred as Document Object Model
Q.46 Specify the advantages of using External JavaScript?
Some of the advantages of using External JavaScript in our code ae -
1. Separation of Code is done.
2. Code Maintainability is Easy.
3. Performance is better.
Q.47 Specify the primary advantages of JavaScript?
Some of the advantages of JavaScript Scripting language are -
1. Lightweight: JavaScript is easy to implement and has small memory footprints.
2. Interpreted: It is an interpreted language such that instructions are executed directly.
3. Object-oriented: JavaScript is an object-oriented language.
4. First class functions: In JavaScript, function can be used as a value.
5. Scripting Language: JavaScript is a language in which instructions are written for a run-time environment.
Q.48 What browser have you used for debugging?
We can enable debugging in the browser by pressing ‘F12’ key in the keyboard. Thereafter chose the ‘Console’ tab to view the result. Such that in Console, we can set breakpoints and view the value in variables. Also the modern browsers have a built-in debugger with them (For instance Chrome, Firefox, Opera, and Safari) which can be turned ON and OFF.
Q.49 How do you describe JavaScript Hoisting?
When we use ‘JavaScript Hoisting’ method, an interpreter runs the code, such that all the variables are hoisted to the top of the original /current scope. When we have a variable declared anywhere inside the JavaScript code then it is brought to the top. JavaScript Hoisting method is only applicable for the declaration of a variable and not applicable for initialization of a variable. Also functions are also hoisted to the top, whereas function explanations are not hoisted to the top.
Q.50 How do you define JavaScript ‘Strict Mode’?
‘Strict mode’ is a restricted variant of JavaScript. In general, JavaScript is ‘not very strict’ in throwing errors. But in ‘Strict mode’ which throws all types of errors, even the silent errors. Thus, the process of debugging becomes easier and the chances for making mistake for the developer is reduced.
Q.51 How do you define self invoking functions?
Self invoking functions are also referred as ‘Immediately Invoked Function Expressions’ or ‘Self Executing Anonymous Functions’. Self invoking functions are invoked automatically in the code, hence they are named as ‘Self Invoking Functions’. In general, we define a function and invoke it, yet if we want to execute a function automatically where it is explained, and if we are not going to call it again, we can use anonymous functions. Also these kind of function have no name.
Get Govt. Certified Take Test