<<

CHAPTER 4: AND FRAMES IN HTML5

1. Fill in the blanks:-

a. b. small hand c. mailto: d. href e. blue f. current g. target h. i. pixels j. loop

2. Write True or False: -

a. True b. True c. False d. True e. True f. False g. True h. True i. False

3. Choose the correct option:-

a. b. All of these c. href d. # e. _self f. All of these g. Both (i) and (ii) h. Controls i. Active j. autoplay 4. Answers to Short Answer Questions:

a. Links are generally indicated by an underlined text and appear in a different color, usually blue or purple, depending on whether the links has been visited or not. b. URL stands for Uniform Resource Locator. c. The HTML tag that we use to create a link is called the anchor tag . The tag is a container element as it has an ON tag and an OFF tag . d. When we move a mouse pointer over a hyperlink, the pointer changes its shape from an arrow to a small hand. e. Default visited link is purple and active link is red. f. The target attribute of the anchor tag specifies where to open the linked document. g. The

h. The autoplay attribute of the

CLASS 10 COMPUTER SCIENCE CHAPTER 6 INTRODUCTION TO JAVASCRIPT

** Students are instructed to write the following answers as well as the answers given previously in your computer booklets. In case you do not have your computer booklets with you, write it in a new booklet**

1. FILL IN THE BLANKS a. Alert b. Variable c. Modulus d. ! (NOT) e. Conditional 2. STATE TRUE OR FALSE a. False b. False c. False d. True e. True 3. MULTIPLE CHOICE QUESTIONS a. (i) 1employeename b. (ii) {} c. (ii) break d. (ii) Prompt e. (ii) A f. (ii) Relational operator 4. SHORT ANSWER QUESTIONS a. What are the three data types in JavaScript? ANS. The three data types in JavaScript are: (i)Numbers eg. 453, 98.12 etc. (ii)Strings eg. “Python Programming”, etc. (iii) Boolean eg. True or False b. How will you declare variable sub1, sub2 and sub3 in JavaScript? ANS. When we are declaring a variable in JavaScript, we start with the letters var (short for variable) So, the answer would be var sub1 var sub2 var sub3 c. Name the different forms of if statement. ANS. Different forms of if statement are: (i) if statement (ii) if….else statement (iii)if…..else if statement d. Name three logical operators ANS. The three logical operators are: (i)&& (AND) (ii)|| (OR) (iii) ! (NOT) e. Write the statements equivalent to A++ and A— ANS. The statement equivalent to A++ : the increment operator (++) increases the value of A stored in a variable by one. A-- : the decrement operator (--) decreases the value of A store in a variable by one. f. Write the shorthand form for the following: A=A+15 B=B+1 ANS. The shorthand form of the following are: (i)A=A+15  A+=15 (ii) B=B+1  B+=1 5. LONG ANSWER QUESTIONS a. Explain the two types of comments in JavaScript? ANS. The two types of comments in JavaScript are: (i)SINGLE LINE COMMENT It starts with a pair of slash sign (//). The browser ignores anything from the pair of slash sign (//) till the end of that same line. For eg. //single line comment (ii) MULTI-LINE COMMENT It is also known as Block Comment. It includes more than one line between /* and */ characters. The browser ignores the statements between the characters. For eg. /* this is a block comment*/ b. What are the rules for naming a JavaScript variable? ANS. The rules for naming a JavaScript variable are: i. The name should begin with a letter or the underscore character. It should not start with a digit. The first character is followed by letters, digits or underscore sign. ii. It should not have a reserved word. iii. We cannot have spaces in a variable name. iv. JavaScript is case sensitive. Thus, for example, name, NAME and Name are treated as three different variables. c. What are the limitations of switch statement? ANS. The limitations of switch statement are: i. The case cannot be a variable. For eg. case n: where n is a variable ii. The case label cannot be a range. For eg, case (1..3). This is not a valid constant d. What is the difference between simple and compound statements? ANS. The difference are as follows: SIMPLE STATEMENT COMPOUND STATEMENT 1. A simple statement consists of a 1. A compound statement single instruction. consists of several instructions 2. It does not require braces to grouped in a block. enclose it. 2. Such statements must be enclosed in braces if we wish to treat them all as single statement. e. Explain the working of the conditional operator with an example. ANS. The conditional operator evaluates an expression and returns the value written after ‘?’ if the condition evaluated is TRUE. In case the result is FALSE, the value after ‘:’ is returned. The general format is: var result = condition? “TRUE”: “FALSE”; To understand the concept of this operator, we must do the following: i. Type a program using JavaScript coding in Notepad and save it as html.file. ii. First we set a value for the variable. Eg. ‘age’ as 20. The condition whether age is greater than 18 (e.g.) is tested. It the result is true, the text after the question mark gets placed in the result variable but if its false, the text after the colon will be placed in the result variable. iii. Then we open the html file in Internet Explorer. The output will appear.

*********