JavaScript Class 11 Questions and Answers

Teachers and Examiners (CBSESkillEduction) collaborated to create the JavaScript Class 11 Questions and Answers. All the important Information are taken from the NCERT Textbook Web Application (803) class 11.

JavaScript Class 11 Questions and Answers

1. What is an editor?
Answer – Web developers can produce and change HTML code more quickly and easily by using a sort of software called an HTML editor.

2. What do you understand by a web browser?
Answer – The term “web browser,” sometimes known as a “browser,” refers to software used to access and view webpages. Microsoft Edge, Internet Explorer, Google Chrome, Mozilla Firefox, and Apple Safari are popular web browsers.

3. What are the major types of browser available today?
Answer – Google Chrome, Microsoft Edge (formerly Internet Explorer), Mozilla Firefox, and Apple’s Safari are the most widely used web browsers.

4. What is the advantage of using JavaScript over HTML?
Answer – While JavaScript offers an interface for end users to interact and create dynamic content, HTML offers the actual content. While JavaScript provides a dynamic environment to manage the dynamic events on the web pages, HTML is primarily utilized to create static web content.

5. What are the steps needed to create and run a simple program using JavaScript?
Answer –
Step 1 : Open Notepad file
Step 2 : Write JavaScript code using HTML
Step 3 : Save the file with file name using extension .html or .htm
Step 4 : Open the location, where you have save the file
Step 5 : Double Click on the file

6. Which attribute of the <script> tag helps you include an external JavaScript file?
Answer – The “SRC” attribute is used to insert External JavaScript file –
<script type=”text/javascript” src=”code.js”></script>

7. What are the three ways in which JavaScript can be included?
Answer – The three way to include JavaScript in HTML are –
a. External JavaScript – <script src=”file.js”></script>
b. Internal JavaScript – <script> Write Script code</script>
c. Inline JavaScript – <input type=”button” value=”Test” onClick=”function()” />

8. JavaScript is “interpreted” – what does this imply?
Answer – JavaScript is not a compiler language; rather, it is an interpreted language. An interpreted language is one in which instructions are executed by implementations without first being translated into machine code. Computed programmes execute more quickly than interpreted ones. The compiled programme runs faster than the interpreted programme.

9. Explain the role of case sensitivity in JavaScript.
Answer – JavaScript is a case-sensitive language. JavaScript treated uppercase and lowercase in different manners, for example – Keywords, Variables, Function name or any other identifiers.

10. how to use multiple line comments in JavaScript.
Answer – Block comments in Javascript are multiline comments that begin with a forward slash and an asterisk (/*) and finish with an asterisk and a forward slash (*/).
/* Add your comment */

11. What is a variable?
Answer – A variable in programming is a value that can change based on external factors or data that has been supplied to the programme. A programme typically consists of data that it uses while running and instructions that tell the machine what to execute.

12. Differentiate between local and global scope of a variable.
Answer – A global variable is one that can be accessed from anywhere. A local variable is a variable that can be accessed in the function only.

13. What is a constant variable?
Answer – Any variable whose value is constant throughout your programme cannot be updated or changed at the run time. Constant variable is declared at the time of initialization.

14. What are the major primitive types?
Answer – There are 7 major type of primitive data types –
a. String
b. Number
c. Bigint
d. Boolean
e. Undefined
f. Symbol
g. Null

15. What are undeclared and undefined variables?
Answer – An undefined variable is one that has been declared but has no value. The term “undeclared variable” refers to a variable that is completely absent from the programme.

16. What is a string?
Answer – Any group of characters that a script interprets literally is known as a string. Strings include things like “hello world” and “LH01876HY,” .

17. What are two of the benefits of using variables?
Answer – Two benefits of using variables are –
a. Variables can store multiple types of data using data types.
b. Variable saves unused memory.

18. What the factors to be considered when naming the variable.
Answer – The naming rules for variable are –
a. The first character must be a letter or an underscore(_), or dollar sign ($).
b. JavaScript variable names are case sensitive.
c. There is no limit of length of the variable name.

19. Write any five valid variable names.
Answer – The five valid variable name are –
a. num
b. num2add
c. _hello
d. $hello
e. my_number

20. Write any five invalid variable names.
Answer – The five invalid variable name are –
a. total%
b. 2numadd
c. function
d. *num
e. var

21. What is the difference between null and undefined values?
Answer – A value that has been assigned is null. It means nothing. Undefined refers to a variable that has been declared but not yet defined.

22. What are composite data types?
Answer – When a data type declares several identical or dissimilar data under a single variable declaration, or when the data type includes multiple values grouped together, the data type is referred to as a composite data type. Example of composite data type is array. int a[ ] = {1,2,3,4,5};

23. What is an operator?
Answer – In computer programming, an operator is a symbol that often denotes an action or process. These symbols were modified from logic and mathematics. A specific value or operand can be manipulated by an operator.

24. What is the associativity of an operator?
Answer – The operator associativity has an impact on the evaluation of expressions as well. Associativity refers to the direction that the full phrase is evaluated (from right to left or from left to right).

25. What is an precedence of operator.
Answer – An operator’s precedence determines how “tightly” it binds two phrases together. Because the multiplication (“*”) operator has priority over the addition (“+”) operator, the result to the formula 1 + 5 * 3 is 16 and not 18, for instance. If necessary, parentheses can be used to enforce precedence.

26. What are the major types of operators supported by JavaScript?
Answer – The major types of operators supported by JavaScript are –
a. Arithmetic Operators
b. Comparison Operators
c. Logical Operators
d. Assignment Operators
e. Ternary Operators

27. What would be the result of 1+2+“3” in JavaScript?
Answer – Result will be 33

28. What is the difference in the outputs that you get when you use the following operators =; == ; and ===.
Answer –
a. The assignment operator equal to (=) changes the value of the expression on its right to that of the variable to the left of the equal sign.
b. A comparison operator called double equals (==) changes operands of the same type before comparison.
c. In JavaScript, the stringent equality comparison operator === (Triple equals) returns false for values that are not of the same type. With this operator, type casting is done for equality. It will give a false result if we compare 2 with “2” using the comparison operator ===.

29. Explain what you understand by Modulo operator.
Answer – The modulus operator, which operates between two accessible operands, is an addition to the JavaScript arithmetic operators. To obtain a result, it divides the supplied numerator by the supplied denominator. To put it another way, it results in an integer division remainder. As a result, the leftover amount is likewise always an integer. example 10%2 the result will be 5;

30. What is conditional operator?
Answer – Ternary operator is also known as conditional operator. The ternary operator (?:) is used to express a condition (it takes three operands). The first operand is implicitly changed to boolean by the conditional operator.

31. What is a dialog box?
Answer – The dialogue box is a graphical control element that looks like a small window and gives the user information and asks for a response. There are three types of dialogue boxes used by JavaScript: ALERT, PROMPT, and CONFIRM.

32. What is Window object?
Answer – All browsers support the window object. It symbolizes the window of the browser. All variables, functions, and objects that are global to JavaScript are immediately added as members of the window object. The window object’s characteristics include global variables. The window object’s methods are known as global functions.

33. What is alert() method?
Answer – The alert() method shows an alert box with an OK button and a message. When you want the user to get information, you utilise the alert() method.

34. What is prompt() method?
Answer – The user is prompted for input in a dialogue box by the prompt() method. If the user selects “OK,” the prompt() method returns the input value; otherwise, it returns null.

35. What is confirm method()?
Answer – A modal dialogue with an optional message and the buttons OK and Cancel is displayed using the confirm() method. If the user hits “OK,” it returns true; if not, it returns false. Until the box is closed, the user is unable to view other areas of the page.

36. What happens when a user clicks the cancel button of the prompt dialog box?
Answer – If the user clicks the Cancel button, prompt( ) returns null.

37. What is the difference between confirm and alert method?
Answer – If we want the user to receive the information, we utilize an alert box. If we want the user to confirm or approve something, we use the confirm box.

38. Create a JavaScript program that prompts the user for a phone number and then asks the user for confirmation.
Answer –

var phoneno;
phoneno=confirm("Please Confirm" + prompt("Enter Phone Number"));

39. Write a program to ask the user to input two values and then perform the arithmetic operation and display the result.

var num1,num2,sum;
num1=parseInt(prompt("Enter Number"));
num2=parseInt(prompt("Enter Number"));
document.write("Sum is " + sum);

Employability Skills Class 11 Notes

Employability Skills Class 11 MCQ

Employability Skills Class 11 Questions and Answers

Web Application Class 11 Notes

Web Application Class 11 MCQ

Web Application Class 11 Questions and Answers