Tamilnadu State Board New Syllabus Samacheer Kalvi 11th Computer Applications Guide Pdf Chapter 14 Introduction to Javascript Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 11th Computer Applications Solutions Chapter 14 Introduction to Javascript

11th Computer Applications Guide Introduction to Javascript Text Book Questions and Answers

Part – I

I. Choose The Correct Answers

Question 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
Answer:
d) JavaScript

Question 2.
Expand CGI _________.
a) Common Gateway Interface
b) Complex Gateway Information
c) Common Gateway Information
d) Complex Gateway Interface
Answer:
a) Common Gateway Interface

Question 3.
JavaScript programming language is used to develop the _________.
a) Dynamic Web Page
b) Window
c) Web Page
d) Home Page
Answer:
a) Dynamic Web Page

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 4.
The Dynamic Web Page help to save server’s _______
a) Work
b) Route
c) Traffic
d) Pvath
Answer:
c) Traffic

Question 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
Answer:
b) Dynamic Web Page

Question 6.
Java Scripts can be implemented using which statements?
a) <head>
b) <Java>
c) <script>
d) <text>
Answer:
c) <script>

Question 7.
Expand DHTML _______.
a) Distance Hyper Text Markup language
b) Dynamic Hyper Text Markup language
c) Distance High Text Markup language
d) Dynamic High Text Markup language
Answer:
b) Dynamic Hyper Text Markup language

Question 8.
How many attributes specifies that <script> tag in the scripting?
a) 2
b) 3
c) 4
d) 5
Answer:
a) 2

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 9.
Which attribute is used to indicate the scripting language and its value should be sent to ” Text/JavaScript”?
a) Language
b) Text
c) Type
d) Body
Answer:
c) Type

Question 10.
The file reload into the browser use the shortcut key is _________.
a) F2
b) F3
c) F4
d) F5
Answer:
d) F5

Question 11.
JavaScript ignores spaces that appear between _________.
a) Command
b) Scripts
c) Tokens
d) Text
Answer:
c) Tokens

Question 12.
A Data value for variable that appears directly in a program by using a _______.
a) loop
b) Literal
c) Statement
d) Text
Answer:
b) Literal

Question 13.
Which is mostly used to give a warning message to users?
a) Alert Dialog Box
b) Confirm box
c) Prompt box
d) Display box
Answer:
a) Alert Dialog Box

Question 14.
In the below snippet, value of x is var x = 250 + 2-200;
a) 50
b) 52
c) 48
d) 42
Answer:
b) 52

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Part – II

II. Very Short Answers

Question 1.
Write a syntax of <script> tag.
Answer:
The syntax of Java <script> tag;
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 1
Language – This attribute specifies the scripting language.
Type – This attribute is used to indicate the scripting language and its value should be set to “text/javascript”.

Question 2.
What is scope of variables and types of scope variable?
Answer:
Scope of variables – The scope of a variable is the life time of a variable of source code in which it is defined.

  • A global variable has global scope; it can be defined everywhere in the Java Script code.
  • Variables declared within a function are defined only within the body of the function. They are local variables and have local scope.

Question 3.
Write a notes to type casting in JavaScript.
Answer:
Type casting in Java Script – Type conversion is the act of converting one data type into a different data type which is also called as casting. In Java Script there are two type of casting,

  • Implicit casting and
  • Explicit casting

Implicit casting occurs automatically in Java Script when we change the data stored in a variable.

Question 4.
How many Literals in JavaScript and mention its types.
Answer:
A literal is a fixed value given to a variable in source code. Literals are often used to initialize

Question 5.
What is conditional operator? Give suitable example.
Answer:
Conditional Operator (?:)
The ?: is the conditional operator in JavaScript, which requires three operands, hence it is called the ternary operator. The syntax is
var variablename = (condition) ? value1 : value2;

Working of conditional operator:
First condition will be evaluated, if the condition returns true then the value of the left side of the colon is assigned to the variable otherwise the value of the right side of the colon will be assigned the variable.

For example:
var result=(10>15) ?100 :150;
In the above example, since the condition returns false the value 150 will be assigned to result.

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 6.
What are the comments in Java Script?
Answer:
There are two types of comments, Single line and Multiple lines comments.

  1. Single-line comments begin with a double slash (//), causing the interpreter to ignore everything from that point to the end of the line.
  2. Multiple line comments begins with /* and ends with */.

For example:
// JavaScript single line comment .
/* Multiple line
comments */

Question 7.
Write note on types of Operator.
Answer:
JavaScript supports the following operators.

  1. Arithmetic Operators
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operators
  5. String Operators
  6. Increment and Decrement Operators
  7. Conditional Operator
    Unary + and – Operator
  8. typeof Operator

Question 8.
Write the role of variable in JavaScript.
Answer:
Variable is a memory location where value can be stored. Variable is a symbolic name for a value. Variables are declared with the var keyword in JavaScript. Every variable has a name, called identifier.

Every variable has a data type that indicates what kind of data the variable holds. The basic data types in JavaScript are Strings, Numbers, and Booleans.

Question 9.
What is the use of prompt dialog box?
Answer:
Prompt Dialog Box:
The prompt dialog box is very useful when the user want to pop-up a text box to get user input. Thus, it enables you to interact with the user. The user needs to fill in the text box field and then click OK.

The Syntax of prompt dialog box is:
Prompt(“Message”,”defaultValue”);
(or)
window.prompt(”sometext”,”defaultText”);

Example:
prompt(“Enter Your Name:”,”Name”);
(or)
window.prompt(“Enter Your Name:”,”Name”);

Part – III

III. Short Answers

Question 1.
What are the advantages of programming language?
Answer:
Advantages of Programming Language:

  1. The web pages must be interactive. So to develop such interactive pages (Dynamic Web page) JavaScript programming language is used.
  2. User entered data in the Dynamic Web page can be validated before sending it to the server. This saves server traffic, which means less load on our server.
  3. JavaScript includes such items as Textboxes, Buttons, drag-and-drop components and sliders to give a Rich Interface to site visitors. For example Creating a New email account in any service provider.

Question 2.
Brief the basic data types in Java Scripts.
Answer:
Every variable has a data type that indicates what kind of data the variable holds. The basic data types in JavaScript are Strings, Numbers, and Booleans.

  1. A string is a list of characters, and a string literal is indicated by enclosing the characters in single or double quotes. Strings may contain a single character or multiple characters, including whitespace and special characters such as \n (the newline).
  2. Numbers can be integer or floating-point numerical value and numeric literals are specified in the natural way.
  3. Boolean can be any one of two values: true or false. Boolean literals are indicated by using true or false directly in the source code.

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 3.
Write note on string Operator.
Answer:
String Operators:
One of the built-in features of JavaScript is the ability to concatenate strings. The + operator performs addition on numbers but also serves as the concatenation operator for strings. Because string concatenation has precedence over numeric addition, + will be interpreted as string concatenation if any of the operands are strings. + operator which is also called as the string concatenation operator.

For example:
Using + Operator for concatenating String:
<Html>
<Head>
<Title>Demo Program – To Concatenating (+) Operators in JavaScript </Title>
</Head>
<Body>
<script language=”javascript” type=”text/
javascript”>
var String1 = “Java”;
var String2 = “Script”;
var String3=String1+String2;
document.write(“<br>String1 : “+Strlngl);
document.write(“<br>String2 : “+String2);
document.write/”<br> <br>Concatenated String
of String! and String2 : “+String3);
</script>
</Body>
</Html>

OUTPUT:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 2

Question 4.
Write about <script> tag.
Answer:
JavaScript can be implemented using <script>… </script> tags. The <script> tag containing JavaScript can be placed anywhere within in the web page, but it is normally recommended that should be kept it within the <head> tags. The <script> tag alerts the browser program to start interpreting all the text between these tags as a script commands.

The syntax of JavaScript segment in Hyper Text Markup Language (HTML) or Dynamic Hyper Text Markup Language (DHTML) is as follows:
<script language=”javascript” type=”text/
javascript”>
JavaScript code
</script>

The <SCRIPT> tag takes two important attributes:

  1. Language – This attribute specifies the scripting language. Typically, its value will be javascript.
  2. Although recent versions of HTML (Extensible HyperText Markup Language – XHTML, its successor) have phased out the use of this attribute is optional.
  3. Type – This attribute is used to indicate the scripting language and its value should be set to “text/javascript”

Question 5.
What are the uses of Logical Operators?
Answer:
Logical Operators:
Logical operators perform logical (boolean) operations. Logical operators combine or invert boolean values. Once comparisons are made, the logical operators && (AND), 11 (OR) and ! (NOT) can be used to create more complex conditions.

Logical or Boolean operators:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 3

Usage :
The rules are as follows:

  • For && (AND) the result is false if the first operand is false; otherwise, the result is the Boolean value of the second operand.
  • For i | (OR) the result is true if the first operand is true; otherwise, the result is the Boolean value of the second operand.
  • For I (NOT) the result is true if the operand is false; otherwise, the result is true.

HTML CODE Using Logical Operators:
<Html>
<Head>
<Title>Demo Program – To test Logical Operators in JavaScript. </Title>
</Head>
<Body>
<script language=”javascript” type=”text/
javascript”>
var valuel = 522, value2=10;
document.write(“<br>Datal ; “+valuel);
document.write(“<br>Data2 ; “+value2);
var res1=((valuel>100) && (vaiuel>601));
var res2=((valuel>100) || (valuel>601));
var res3=(!(valuel!=va!ue2));
document.write(“< br> < br>Whether Data 1 > 100
AND Data 1>601 : “+res1);
document.write(”<brxbr>Whether Datal>600 OR Data 1>601 : “+res2);
document.write(“<br>Whether IDatal != Data2 : “+res3);
</script>
</Body>
</Html>

Output:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 4

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 6.
Difference between the increment and Decrement operator.
Answer:
Increment and Decrement Operators:
The ++ operator increments its single operand. The operator converts its operand to a number, adds 1 to that number, and assigns the incremented value back into the variable. The return value of the ++ operator depends on its position relative to the operand.

When ++ is used before the operand, where it is known as the pre-increment operator, it increments the operand and evaluates to the incremented value of that operand. When used after the operand, where it is known as the post-increment operator, it increments its operand but evaluates to the un-incremented value of that operand.

Consider the difference between these two lines of code:
var m = 1, n = ++m; // m and n are both 2
var m = 1, n = m++; // m is 2, n is 1
The — operator decrements its single operand. It converts the value of the operand to a number. subtracts 1, and assigns the decremented value back to the operand. Like the ++ operator, the return value of — depends on its position relative to the operand. When used before the operand, it decrements and returns the decremented value. When used after the operand, it decrements the operand but returns the undecremented value.
var m = 2, n = –m; // m and n are both 1
var m = 2, n = m–; // n is 2, n is 1

Part – IV

IV. Explain In Brief

Question 1.
Explain about the popup dialog boxes in JavaScript.
Answer:
JavaScript:
JavaScript supports three important types of dialog boxes. Dialog boxes are also called as Popup Boxes, These dialog boxes can be used to raise an alert, or to get confirmation on any input or to have a kind of input from the users. JavaScript supports three kind of popup boxes: Alert box, Confirm box, and Prompt box.

Alert Dialog Box:
An alert dialog box is mostly used to give a warning message to the users. For example, if one input field requires to enter some text but the user does not provide any input, then as a part of validation, you can use an alert box to give a warning message. Alert box gives only one button “OK” to select and proceed.

The syntax of alert box is:
Alert (“Message”);
(or) Window.alert (“Message”);

Example:
alert (“Name is compulsory entry”);
(or) window.alert (“Name is compulsory entry”);

Alert Dialog Box Code:
<Html>
<Head>
<Title>Demo Program – To test Alert Dialog Box in JavaScript </Title>
</Head>
<Body>
<script ianguage=”javascript” type=”text/
javascript”>
var value1 = 522, value2=10;
window.alert(“Data1 : “+value1);
alert(“Data1 :”+value2);
</script>
</Body>
</Html>

Output:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 5

Confirm Dialog Box:
A confirmation dialog box is mostly used to take user’s consent on any option. It displays a dialog box with two buttons: OK and Cancel. If the user dicks on the OK button, the confirm() will return true. If the user clicks on the Cancel button, then confirm() returns false.

The syntax of confirm dialog box is:
confirm (“message”); (or) window,confirm (“message”);

Example:
confirm (“Hai Do you want to continue:”);
(or)
window.confirm (“Hai Do you want to continue:”);

Confirm Dialog Box Code:

Output:

Prompt Dialog Box:
The prompt dialog box is very useful when the user want to pop-up a text box to get user input. Thus, it enables you to interact with the user. The user needs to fill in the text box field and then click OK.

The prompt dialog box is displayed using a method called prompt() which takes two parameters:

a label which you want to display in the text box and
a default string to display in the text box.

This dialog box has two buttons: OK and Cancel. If the user clicks the OK button, the prompt() will return the entered value from the text box. If the user clicks the Cancel button, the prompt() returns null.

The Syntax of prompt dialog box is: Prompt(“Message”,”defaultValue”);
(or)
window.promptC’sometext””defaultText”);

Example:
prompt (“Enter Your Name:”,”Name”);
(or)
window.prompt (“Enter Your Name:”,”Name”);

Prompt Dialog Box Code:

OUTPUT:

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 2.
Explain about the Arithmetic operator with suitable example.
Answer:
Arithmetic Operators:
JavaScript supports all the basic arithmetic operators like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%, also known as the remainder operator).

Arithmetic Operators:

HTML CODE Using Arithmetic Operators:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 11
Output:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 11a

11th Computer Applications Guide Introduction to Javascript Additional Important Questions and Answers

Part – I

I. Choose The Correct Answers

Question 1.
Java script introduced by _________.
a) Netscape
b) Sun Inc.
c) Netscape and Sun Inc.
d) Borland International
Answer:
c) Netscape and Sun Inc.

Question 2.
Java script introduced on _______.
a) December 6, 1995
b) December 5, 1995
c) December 4, 1995
d) December 4, 1985
Answer:
c) December 4, 1995

Question 3.
________ provides a common- scripting language for Web developers to design, test and deploy Internet Applications.
a) Java
b) Java Script
c) C++ V
d) None of these
Answer:
b) Java Script

Question 4.
Java script is used to develop _______.
a) Interactive Web Pages
b) Dynamic Web Pages
c) Static Web Pages
d) Either A or B
Answer:
d) Either A or B

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 5.
_______ saves server traffic, which means less load on your server.
a) Simple Web Pages
b) Dynamic Web Pages
c) Static Web Pages
d) Either A or B
Answer:
b) Dynamic Web Pages

Question 6.
JavaScript includes ________ item to give a rich Interface to website visitors.
a) Textboxes / Buttons
b) Drag-and-drop components
c) Sliders
d) All the above
Answer:
d) All the above

Question 7.
JavaScript can be implemented using _______tag.
a) <script>
b) <Jscript>
c) <JS>
d) None of these
Answer:
a) <script>

Question 8.
The <script> tag containing JavaScript can be placed _______ in the web page.
a) any where
b) <Head> section alone
c) <body> section alone
d) None of these
Answer:
a) any where

Question 9.
It Is normally recommended that <script> tag should be kt it within the ______ tags.
a) any
b) <Head>
c) <body>
d) None of these
Answer:
b) <Head>

Question 10.
DHTML expanded as ______.
a) Dynamic Hyper Text Machine Language
b) Dynamic Hyper Text Markup Language
c) Dynamic Heavy Text Markup Language
d) Direct Hyper Text Markup Language
Answer:
b) Dynamic Hyper Text Markup Language

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 11.
The <SCRIPT> tag takes ______ important attributes.
a) two
b) three
c) four
d) five
Answer:
a) two

Question 12.
______ is the <SCRIPT> tag attribute.
a) Language
b) Type
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 13.
______ attribute of <Script> tag specifies that the scripting language.
a) Language
b) Type
C) Both A and B
d) None of these
Answer:
a) Language

Question 14.
_______ attribute of <Script> Is used to indicate the scripting language and its value should be set to ‘text/javascript’.
a) Language
b) Type
c) Both A and B
d) None of these
Answer:
b) Type

Question 15.
_______ Is the set of elementary rules that specifies how to write programs in that language.
a) Lexical structure
b) Logical structure
c) Procedural structure
d) None of these
Answer:
a) Lexical structure

Question 16.
______ Is the lowest-level syntax of a language.
a) Lexical structure
b) Logical structure
c) Procedural structure
d) None of these
Answer:
a) Lexical structure

Question 17.
The _______ specifies venable names, the delimiter characters for comments, and how one program statement ¡s separated from the next.
a) Lexical structure
b) Logical structure
c) Procedural structure
d) None of these
Answer:
a) Lexical structure

Question 18.
JavaScript Is a ______ language.
a) Non- case-sensitive
b) Case-sensitive
c) Either A or B
d) None of these
Answer:
b) Case-sensitive

Question 19.
JavaScript ignores spaces that appear between ______ in programs.
a) Identifiers / Operators
b) Punctuator Constants
c) Keywords
d) All the above
Answer:
d) All the above

Question 20.
JavaSaipt supports ________ styles of comments.
a) three
b) three
c) two
d) five
Answer:
c) two

Question 21.
_______ Is a single line comment In Javascript.
a) //
b)\\
c) / * */
d) None of these
Answer:
a) //

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 22.
_______ is a multi line comment In Javascript.
a) //
b) \\
c) /* */
d) None of these
Answer:
c) /* */

Question 23.
JavaScript uses the _______ to separate statements.
a) Semicolon(;)
b) Colon( : )
c) comma (,)
d) None of these
Answer:
a) Semicolon(;)

Question 24.
Many JavaScript programmers use to explicitly mark the ends of statements.
a) SemIcolon (;)
b) Colon (:)
C) comma(,)
d) None of these
Answer:
a) SemIcolon (;)

Question 25.
A _______ is a data value for variable that appears directly in a program.
a) Keyword
b) Operator
c) Literal
d) None of these
Answer:
c) Literal

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 26.
In JavaScript, identifiers are used to _______.
a) Name variables
b) Name functions
c) Provide labels for certain loops
d) All the above
Answer:
d) All the above

Question 27.
In JavaScript ________ cannot be used as identifiers in the programs.
a) Keywords
b) Small letters
c) Capital letters
d) None of these
Answer:
a) Keywords

Question 28.
________ is a memory location where value can be stored.
a) Keyword
b) Operator
c) Literal
d) Variable
Answer:
d) Variable

Question 29.
________ is a symbolic name for a value.
a) Keyword
b) Operator
c) Literal
d) Variable
Answer:
d) Variable

Question 30.
Variables are declared with the _________ keyword in JavaScript.
a) declare
b) var
c) jsvar
d) None of these
Answer:
b) var

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 31.
Every variable has a name, called __________.
a) Keyword
b) Idetifier
c) Literal
d) Variable
Answer:
b) Idetifier

Question 32.
The basic data types in JavaScript is __________
a) Strings
b) Numbers
c) Booleans
d) All the above
Answer:
d) All the above

Question 33.
A ________is a list of characters, and a string literal is indicated by enclosing the characters in single or double quotes.
a) Strings
b) Numbers
c) Booleans
d) All the above
Answer:
a) Strings

Question 34.
_________ can be integer or floating-point numerical value and numeric literals are specified in the natural way.
a) Strings
b) Numbers
c) Booleans
d) All the above
Answer:
b) Numbers

Question 35.
__________ can be any one of two values: true or false.
a) Strings
b) Numbers
c) Booleans
d) All the above
Answer:
c) Booleans

Question 36.
________ keyword allocates storage space for new data.
a) declare
b) var
c) jsvar
d) allocate
Answer:
b) var

Question 37.
__________ keyword indicates to the interpreter that a new identifier is in use.
a) declare
b) var
c) jsvar
d) allocate
Answer:
b) var

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 38.
In Javascript, the first character of a variable name must be a(n) __________.
a) Letter
b) underscore
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question39.
Identify the false statement from the following regarding variable name.
a) JavaScript variable names are case sensitive.
b) There is no limit to the length of the variable name.
c) JavaScript’s reserved words can be used as a variable name.
d) Number cannot be as the first character.
Answer:
c) JavaScript’s reserved words can be used as a variable name.

Question 40.
The ________ of a variable of source code in which it is defined,
a) Scope
b) Validity
c) Position
d) None of these
Answer:
a) Scope

Question 41.
In Javascript, _______scope is possible for a variable.
a) Local
b) Global
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 42.
________ scope variable can be defined everywhere in the JavaScript code.
a) Local
b) Global
c) Both A and B
d) None of these
Answer:
b) Global

Question 43.
Variables declared within a function have _________ scope in JavaScript code.
a) Local
b) Global
c) Both A and B
d) None of these
Answer:
a) Local

Question 44
Identify the false statement from the following regarding variable declaration.
a) In JavaScript there is no need to indicate data type during variable declaration.
b) JavaScript variables are untyped.
c) JavaScript variables are dynamically datatyped.
d) In JavaScript, no need to declare a variable.
Answer:
d) In JavaScript, no need to declare a variable.

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Question 45.
A ________ is a fixed value given to a variable in source code.
a) Identifier
b) Literal
c) Keyword
d) None of these
Answer:
b) Literal

Question 46.
Type conversion is the act of converting one data type into a different data type which is also called as ________.
a) Casting
b) Compilation
c) Linking
d) Sampling
Answer:
a) Casting

Question 47.
In JavaScript there are _________ type of casting.
a) three
b) four
c) two
d) only one
Answer:
c) two

Question 48.
In JavaScript-__________ is a type of casting.
a) Implicit
b) Explicit
c) Both A and B
d) None of these
Answer:
a) Implicit

Question 49.
___________ casting occurs automatically in JavaScript when you change the data stored in a variable.
a) Implicit
b) Explicit
c) Both A and
d) None of these
Answer:
a) Implicit

Question 50.
Operators are used for JavaScript’s ________ expressions.
a) Arithmetic
b) Comparison
c) Logical/Assignment
d) All the above
Answer:
d) All the above

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Part – II

II. Very Short Answers

Question 1.
What is variable in JavaScript code?
Answer:
Variable is a memory location where value can be stored. Variable is a symbolic name for a value. Variables are declared with the var keyword in JavaScript. Every variable has a name, called identifier.

Example:
var n1 = 522; Here n1 is a variable. 522 is a value stored on it.

Question 2.
What is liteal in JavaScript language.
Answer:
Java Script Literals:
A literal is a fixed value given to a variable in source code. Literals are often used to initialize variables. Values may be Integer, Floating point, Character, String and Boolean.

Example:
var int_const=250; //Integer constant/’/
var float_const=250.85; //Floating point constant//
var char_const=’A’; //Character constant//
var string_const=”Raman”; //String constant//
var boolean_const=true; //Boolean constant//

Question 3.
Give the syntax of write( ) statement with an example.
Answer:
write statement general syntax: document write (’”string ” + var);

Example:
document.write (“The Sum of Data1 and Data2 : “+sum);

Question 4.
Write note on assignment operator.
Answer:
Assignment Operator:
In JavaScript, = is an assignment operator, which is used to assign a value to a variable. Often this operator is used to set a variable to a literal value.

Example:
var number1=10; var number2=numberl; var name=”Computer Science”; var booleanvar=true;

Question 5.
What is the use of type of operator?
Answer:
type of Operator:
The type of operator is used to get the data type (returns a string) of its operand. The operand can be either a literal or a data structure such as a variable, a function, or an object. The operator returns the data type.

Syntax:
type of operand or
type of(operand)

type of returns: boolean, function, number, string, and undefined. The following table summarizes possible values returned by the type of operator.
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 12

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Part – III

III. Short Answers

Question 1.
What are the rules for naming a variable?
Answer:
a) The first character must be a letter or an underscore (_). Number cannot be as the first character.

b) The rest of the variable name can include any letter, any number, or the underscore, we can’t use any other characters, including spaces, symbols, and punctuation marks.

c) JavaScript variable names are case sensitive. That is, a variable named Register Number is treated as an entirely different variable then one named register number.

d) There is no limit to the length of the variable name.

e) JavaScript’s reserved words cannot be used as a variable name. All programming languages have a supply of words that are used internally by the language and that cannot be used for variable names.

Question 2.
Write note on expression.
Answer:
An expression is simply one or more variables and/or constants joined by operators. An expression is evaluated and produces a result.
The result of all expressions may be either an integer or floating-point value or Boolean value. There are three types of expressions as follows:

  1. Arithmetic expressions
  2. Relational expressions
  3. Logical expressions

Question 3.
Tabulate the shorthand arithmetic operators with example.
Answer:
Shorthand Arithmetic operators:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 13

Question 4.
What are the relational or comparison operators used in JavaScript? Explain.
Answer:
Relational or Comparison Operators:
Relational operators are also called as Comparison operators, they compares two values and the result is true or false. JavaScript provides a rich set of relational operators including == (equal to), != (not equal to), < (less than), > (greater than), <= (less than or equal to), and >= (greater than or equal to). Using a relational operator in an expression causes the expression to evaluate as true if the condition holds or false if otherwise.

Relational or Comparison Operators:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 14

HTML Code:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 15

Output:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 16

Question 5.
What is conditional operator or ternary operator? Explain?
Answer:
Conditional Operator (?:)
The ?: is the conditional operator in JavaScript, which requires three operands, hence it is called the ternary operator.
The syntax is
var variablename=(condition) ? value1 : value2;
In the syntax condition may be relational expression or logical expression. First condition will be evaluated, if the condition returns true then the value of the left side of the colon is assigned to the variable otherwise the value of the right side of the colon will be assigned the variable. For example,
var result=(10> 15)?100 :150;
In the above example, since the condition returns false the value 150 will be assigned to result.

HTML Code:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 17

Output:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 18

Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript

Part – IV

IV. Explain In Brief

Question 1.
Write a HTML code using relational operator to compare two data.
Answer:
HTML CODE:
<Html>
<Head>
<Title>Demo Program – To test Relational(Comparison) Operators in JavaScript </Title>
</Head>
<Body>
<script language=”javascript” type=”text/ javascript”> ,
var value1 = 522, value2=10;
document.write(“<br>Data1 : “+value1);
document.write(“<br>Data2 : “+value2);
document.write(“<br><br>Whether Data1= Data2 : “+(value1==value2));
document.write(“<br>Whether Data1< Data2 : “+(value1<value2));
document.write(“<br>Whether Data1> Data2 : “+(value1>value2));
document.write(“<br>Whether Data1<= Data2 : “+(value1<=value2));
document.write(“<br>Whether Data1>= Data2 : “+(value1>=value2));
document.write(“<br>Whether Data1!= Data2 : “+(value1!=value2));
</script>
</Body>
</Html>

OUTPUT:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 19

Question 2.
Write a HTML code using to test logical operators.
Answer:
HTML CODE:
<Head>
<Title>Demo Program – To test Logical Operators in JavaScript </Title>
</Head>
<Body>
<script language^ “javascript” type=”text/javascript”>
var value1 = 522, vaiue2=10;
document.write(“<br>Data1: “+value1);
document.write(“<br>Data2 : “+value2);
var res1=((value1>100) && (value1>601));
var res2=((value1>100) || (value1>601));
var res3=(!(value1! =value2));
document.write(“<brxbr>Whether Data1>100 AND Data1>601 : “+res1);
document.write(“<brxbr>Whether Data1>600 OR Data1>601 : “+res2);
document.write(“<br>Whether IData1!= Data2 ; “+res3);
</script>
</Body>
</Html>

Output:
Samacheer Kalvi 11th Computer Applications Guide Chapter 14 Introduction to Javascript 20
interested and these activities bring him profit, money, prestige and power. </p> <p> In economic sense, the term business means works, efforts and acts of people, which are connected with the production of wealth and activities, which are directed with the object of making profit.</p> <p> Production and distribution of goods to consumers for a profit constitute business. </p>

Leave a Reply