Introduction to Javascript: book back answers

28 solved questions from the end of this chapter, Class 11 Computer Applications, Tamil Nadu State Board. Each answer is checked against the textbook, and you can open the page that proves it.

← Notes and quiz for Introduction to Javascript

Part-I Choose the correct answer

  1. Which provided a common scripting language to web developers to design, test and deploy Internet Application

    • A) C
    • B) C++
    • C) Java
    • D) JavaScript
    Try it, then show the answer

    D) JavaScript

    JavaScript provides a common scripting language for web developers to design, test and deploy Internet applications.

    From the book: “It provides a common scripting language for Web developers to design, test and deploy Internet Applications.”

  2. Expand CGI

    • A) Common Gateway Interface
    • B) Complex Gateway Information
    • C) Common Gateway Information
    • D) Complex Gateway Interface
    Try it, then show the answer

    A) Common Gateway Interface

    The chapter expands CGI as Common Gateway Interface.

    From the book: “Common Gateway Interface (CGI) programs on the Server”

  3. JavaScript programming language is used to develop the

    • A) Dynamic Web Page
    • B) Window
    • C) Web Page
    • D) Home Page
    Try it, then show the answer

    A) Dynamic Web Page

    JavaScript is used to develop interactive, dynamic web pages.

    From the book: “to develop such interactive pages (Dynamic Web page ) JavaScript programming language is used.”

  4. The Dynamic Web Page help to save server’s

    • A) Work
    • B) Route
    • C) Traffic
    • D) Pvath
    Try it, then show the answer

    C) Traffic

    Validating data on a dynamic web page before sending it to the server saves server traffic.

    From the book: “This saves server traffic, which means less load on your server.”

  5. User entered data, is validated before sending it to server is called

    • A) Server traffic
    • B) Dynamic Web Page
    • C) Server Route
    • D) Web server
    Try it, then show the answer

    B) Dynamic Web Page

    The chapter says user-entered data in a Dynamic Web page can be validated before being sent to the server.

    From the book: “User entered data in the Dynamic Web page can be validated before sending it to the server.”

  6. Java Scripts can be implemented using which statements?

    • A) <head>
    • B) <Java>
    • C) <script>
    • D) <text>
    Try it, then show the answer

    C) <script>

    JavaScript is implemented using script tags in an HTML page.

    From the book: “JavaScript can be implemented using <script>... </script> tags.”

  7. How many attributes specifies that <script> tag in the scripting

    • A) 2
    • B) 3
    • C) 4
    • D) 5
    Try it, then show the answer

    A) 2

    The chapter identifies Language and Type as the two important attributes of the script tag.

    From the book: “The <SCRIPT> tag takes two important attributes −”

  8. Which attribute is used to indicate the scripting language and its value should be sent to “ Text/JavaScript”

    • A) Language
    • B) Text1
    • C) Type
    • D) Body
    Try it, then show the answer

    C) Type

    The Type attribute indicates the scripting language, and its value should be set to text/javascript.

    From the book: “Type − This attribute is used to indicate the scripting language and its value should be set to "text/javascript".”

  9. The file reload into the browser use the shortcut key is

    • A) F2
    • B) F3
    • C) F4
    • D) F5
    Try it, then show the answer

    D) F5

    The chapter says to reload a file in the browser, use Refresh or press F5.

    From the book: “to reload the file into the browser use "Refresh" or press F5 button.”

  10. JavaScript ignores spaces that appear between

    • A) Command
    • B) Scripts
    • C) Tokens
    • D) Text
    Try it, then show the answer

    C) Tokens

    JavaScript ignores spaces between tokens such as identifiers, operators, punctuators, constants and keywords.

    From the book: “JavaScript ignores spaces that appear between tokens”

  11. A Data value for variable that appears directly in a program by using a

    • A) loop
    • B) Literal
    • C) Statement
    • D) Text
    Try it, then show the answer

    B) Literal

    A literal is a data value for a variable that appears directly in a program.

    From the book: “A literal is a data value for variable that appears directly in a program.”

  12. Which is mostly used to give a warning message to users?

    • A) Alert Dialog Box
    • B) Confirm box
    • C) Prompt box
    • D) Display box
    Try it, then show the answer

    A) Alert Dialog Box

    An alert dialog box is mostly used to give a warning message to users.

    From the book: “An alert dialog box is mostly used to give a warning message to the users.”

Very Short Answers

  1. Write a syntax of <script> tag

    Try it, then show the answer

    <script language="javascript" type="text/javascript">

    This is the JavaScript segment syntax given in the chapter.

    From the book: “<script language="javascript" type="text/javascript">”

  2. What is scope of variables and types of scope variable?

    Try it, then show the answer

    The scope of a variable is the lifetime of a variable in the source code in which it is defined. The two types are global scope and local scope.

    A global variable can be defined everywhere in the JavaScript code. A local variable is declared within a function and is defined only within that function's body.

    From the book: “A global variable has global scope; it can be defined everywhere in the JavaScript code.”

  3. Write a notes to type casting in JavaScript

    Try it, then show the answer

    Type conversion, also called casting, is the act of converting one data type into a different data type. JavaScript has implicit casting, which occurs automatically when the data stored in a variable is changed.

    The chapter describes type conversion as converting one data type into another and identifies implicit casting as automatic.

    From the book: “Implicit casting occurs automatically in JavaScript when you change the data stored in a variable:”

  4. How many Literals in JavaScript and mention its types.

    Try it, then show the answer

    The chapter lists five types: Integer, Floating point, Character, String and Boolean.

    These are the literal value types explicitly listed in the chapter.

    From the book: “Values may be Integer, Floating point, Character, String and Boolean.”

  5. What is conditional operator give suitable example.

    Try it, then show the answer

    The ?: operator is a conditional, or ternary, operator that requires three operands. Example: var result=(10>15) ?100 :150;

    The condition is evaluated first; the value before the colon is used if true, otherwise the value after the colon is used.

    From the book: “The ?: is the conditional operator in JavaScript, which requires three operands, hence it is called the ternary operator.”

  6. What are the comments in Java Script?

    Try it, then show the answer

    JavaScript has single-line and multiple-line comments. Single-line comments begin with //; multiple-line comments begin with /* and end with */.

    Comments are remarks in source code and are ignored by the JavaScript interpreter.

    From the book: “There are two types of comments, Single line and Multiple lines comments.”

  7. Write note on types of Operator.

    Try it, then show the answer

    The chapter describes arithmetic, assignment, relational or comparison, logical, string, increment and decrement, typeof, and conditional operators.

    These operators are introduced in the chapter's sections on JavaScript operators and expressions.

    From the book: “Operators are used for JavaScript’s arithmetic expressions, comparison expressions, logical expressions, assignment expressions.”

  8. Write the role of variable in JavaScript.

    Try it, then show the answer

    A variable is a memory location where a value can be stored and is a symbolic name for a value. Variables are declared with the var keyword and have an identifier as their name.

    Variables let JavaScript store and refer to values using names.

    From the book: “Variable is a memory location where value can be stored.”

  9. What is the uses of prompt dialog box?

    Try it, then show the answer

    A prompt dialog box is used to display a text box and get input from the user. It has OK and Cancel buttons; OK returns the entered value and Cancel returns null.

    The prompt method takes a label and a default string to display in the text box.

    From the book: “The prompt dialog box is very useful when the user want to pop-up a text box to get user input.”

Short Answers

  1. What are the advantages of programming language?

    Try it, then show the answer

    JavaScript helps develop interactive dynamic web pages, validate user-entered data before it is sent to the server, and reduce server traffic. It also provides interface elements such as textboxes, buttons, drag-and-drop components and sliders for a rich user interface.

    These advantages are described in the chapter's section on JavaScript programming language.

    From the book: “This saves server traffic, which means less load on your server.”

  2. Brief the basic data types in Java Scripts.

    Try it, then show the answer

    The basic data types are Strings, Numbers and Booleans. A string is a list of characters, a number may be an integer or floating-point value, and a Boolean is true or false.

    Each type represents a different kind of data that a variable can hold.

    From the book: “The basic data types in JavaScript are Strings, Numbers, and Booleans.”

  3. Write note on string Operator.

    Try it, then show the answer

    The + operator concatenates strings. It performs addition on numbers, but if any operand is a string, it is interpreted as string concatenation.

    For example, adding the strings "Java" and "Script" produces "JavaScript".

    From the book: “The + operator performs addition on numbers but also serves as the concatenation operator for strings.”

  4. Write about <script> tag

    Try it, then show the answer

    JavaScript is implemented using <script>...</script> tags. The tags may be placed anywhere in the web page, though the chapter recommends keeping them within the <head> tags. The tag alerts the browser to interpret the text between the tags as script commands. Its important attributes are Language and Type; Type should be set to "text/javascript".

    The script tag identifies the JavaScript code within an HTML page and provides attributes specifying the scripting language.

    From the book: “The <script> tag alerts the browser program to start interpreting all the text between these tags as a script commands.”

  5. What are the uses of Logical Operators?

    Try it, then show the answer

    Logical operators combine or invert Boolean values and can be used to create more complex conditions after comparisons. JavaScript uses && (AND), || (OR) and ! (NOT).

    They allow conditions to be joined or negated.

    From the book: “Logical operators combine or invert boolean values.”

  6. Difference between the increment and Decrement operator.

    Try it, then show the answer

    The ++ operator converts its operand to a number, adds 1 and assigns the result back. The -- operator converts the operand to a number, subtracts 1 and assigns the result back. Prefix forms return the changed value; postfix forms return the original value while changing the operand.

    Both operators can appear before or after the operand, and their returned value depends on that position.

    From the book: “The ++ operator increments its single operand.”

Part –IV Explain in Detail

  1. Explain about the popup dialog boxes in JavaScript.

    Try it, then show the answer

    JavaScript supports three important types of dialog boxes, also called popup boxes. They are used to raise an alert, obtain confirmation, or get input from users.

    1. Alert box: An alert box is mostly used to give a warning message to users. It provides only an OK button to select and proceed.
    2. Confirm box: A confirm box is used to obtain the user's consent on an option. It displays OK and Cancel buttons; the response is true for OK and false for Cancel.
    3. Confirm syntax: A confirmation dialog can be displayed using confirm() or window.confirm(), with a message supplied as its argument.
    4. Prompt box: A prompt box displays a text box to get input from the user and enables interaction.
    5. Prompt arguments: The prompt() method takes a label to display and a default string for the text box.
    6. Prompt response: The prompt box has OK and Cancel buttons. OK returns the entered value, while Cancel returns null.

    Example: var sname = prompt("Please enter your name", "Name");

    Thus, alert, confirm and prompt boxes provide warning, confirmation and input functions in JavaScript.

    From the book: “JavaScript supports three kind of popup boxes: Alert box, Confirm box, and Prompt box.”

Next chapterControl Structure in Javascript