+1 and +2 Computer Science

Previous Question paper answered , and Questions from Textbook

+1 and +2 Computer Application

Previous Question paper answered , and Questions from Textbook

Diploma in Computer Application (DCA)

Previous Question paper answered , and Questions from Textbook.

Master of Computer Applications (MCA)

Previous Question paper answered , and Questions from Textbook

True IQ Computer Online Academy

Contact : +91 9036433020 , mail2trueiq@gmail.com

Pageviews

Showing posts with label Client Side Scripting Using JavaScript. Show all posts
Showing posts with label Client Side Scripting Using JavaScript. Show all posts

Wednesday, 31 July 2019

+2] 6. Client Side Scripting Using JavaScript - Previous Questions chapter wise


                         PLUS TWO COMPUTER APPLICATION

          (+2 Computer Application / Computer Science ,  
Previous Questions Chapter wise ..

                                           Chapter  6 Client Side Scripting Using JavaScript.


1. Explain three different ways to add javascripts in a webpage.

Inside <BODY>

    the scripts will be executed while the contents of the web page is being loaded. The web page starts displaying from the beginning of the document. When the browser sees a script code in between, it renders the script and then the rest of the web page is displayed in the browser window. A script can also be at the bottom of tag. If the scripts are loaded inside the tag or in the tag, they will be loaded along with the HTML code.

Inside<HEAD>

     It is a usual practice to include scripts in the head section of the web page. The main reason for this is that the body section of most of the HTML pages contains a large volume of text that specifies the contents to be displayed on the web page. Mixing a function definition also with this will create a lot of confusion for the web designer for making any kind of modification in the page.More over, the head section of a web page is loaded before the body section. Therefore, if any function call is made in the body section, the function will be executed as the function definition is already loaded in the memory.

External JavaScript file

      We can place the scripts into an external file and then link to that file from within the HTML document. This file is saved with the extension ‘.js’. Placing JavaScripts in external files has some advantages. This is useful if the same script is used across multiple HTML pages or a whole website. It separates HTML and code which makes HTML and JavaScript easier to read and maintain. Storing JavaScript as separate files can speed up page loading.

2. Briefly explain three built in functions in javascript

a. alert() function

             This function is used to display a message on the screen. For example, the statement alert(“Welcome to JavaScript”); will display the following message window on the browser window.

b. isNaN() function

        This function is used to check whether a value is a number or not. In this function, NaN stands for Not a Number. The function returns true if the given value is not a number.

For example.
isNaN(“welcome”); retun the value true.

isNaN(“13.5”); return the value false.

3. What is an external javascript file.Write the advantages of using these files.

      We can place the scripts into an external file and then link to that file from within the HTML document. This file is saved with the extension ‘.js’. Placing JavaScripts in external files has some advantages. This is useful if the same script is used across multiple HTML pages or a whole website. It separates HTML and code which makes HTML and JavaScript easier to read and maintain. Storing JavaScript as separate files can speed up page loading. the JavaScript code is stored as a separate file with the name “check.js”. 

4. In javascript

   a.  Describe any 2 datatypes used?

   b.  Explain any three operators used?

Answers.

    Number : All numbers fall into this category. All positive and negative numbers, all integer and float values (fractional numbers) are treated as the data type number. Thus, 27, -300, 1.89 and -0.0082 are examples of number type data in JavaScript.
  String: Any combination of characters, numbers or any other symbols, enclosed within double quotes, are treated as a string in JavaScript. That is, “Kerala”, “Welcome”, “SCHOOL”, “1234”, “Mark20”, “abc$” and “sanil@123” are examples of string type data.

b. Arithmetic operators, logical operators and assignment operators.

  The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/),modulo division(%)

    Image result for arithmetic operators
   
      Logical operators are &&,|| and !

        Image result for logical operators
Assignment operators are

Image result for assignment operators

Sunday, 28 July 2019

+2] 6. Client Side Scripting Using JavaScript - Solved Questions from text book



            Chapter 6. Client Side Scripting Using JavaScript

((+2 Computer Application / Computer Science ,  
Text book Questions and Answers)



1. Name an attribute of <SCRIPT> tag

Ans. Language

2. In JavaScript ________ function is used to print a text in the body section of an HTML page.

Ans. document.write()

3. ________ is the value given to the language attribute of <SCRIPT> tag to specify that the code follows is JavaScript code.

  Ans. javascript

4. What is the use of JavaScript engine?

     The script code is interpreted at runtime by the JavaScript engine. Every browser has a JavaScript engine. JavaScript engine is a virtual machine for executing JavaScript code. When the browser sees a JavaScript code, it is passed to the script engine for processing. The script engine executes the code. If an HTML page does not contain any JavaScript code, the browser alone is able to render the HTML page.

5. State whether the following statements are true or false

  a. Java Script is the only client side scripting language.----------True

 b.<SCRIPT>  tags  is used to include client side scripting language in an HTML page.----------True

c. An HTML file can contain only one <SCRIPT> tag in it.----------True

d. We can mix JavaScript code with HTML code----------

e. The JavaScript code must be placed within<SCRIPT>and </SCRIPT>  tags.----------True

 f. Every JavaScript statement ends in a semicolon.----------true

6.  Say whether the following statements are true or false:

 a. A function is automatically executed when the browser opens the web page.---------False

 b. A function is usually placed in the head section of a web page.----------False

c. A function can be called any number of times. ----------True

d. Even though a function is defined within the body section, it will not be executed, if it is not called. ------------False

7. List the advantages of using functions in JavaScript.

  The biggest advantage of using a function is that if we need to execute a piece of program code more than once in a web page, the code has to be written only once within the function. We can call the function any number of times to execute it.

8.  number, string and ______ are the basic data types in JavaScript.

Ans. Boolean 

9. true is a ______ type data.

Ans. Boolean

 10. false is a ______ type data. 

Ans. Boolean

11. The keyword used to declare a variable in JavaScript is ______. 

Ans. var

12. The function used to know the type of data in JavaScript is _____. 

Ans. typeof( )

13. What is the use of % operator?

        % operator is a modulus(division remainder).That is a and b are the two operators.then a%b means a divided b and the answer is remainder.For example 6%4 = 2 is the answer.

 14. List the logical operators.

         AND(&&),OR(||) and NOT(!)

15. To select a group of statements in the program code for execution ______ or ______ control structures are used

16 . Give examples of looping statements in JavaScript. 
     Ans. For loop and while loop

17. ______ is a multi branching statement. 

Ans. Switch

18. State whether the following statements are true or false

 a. break statement is used within the switch block.-----------True

 b. If we use switch, we will be using break within it, at least once. ----------True

c. All the program codes written in if-else can be replaced by using switch.-------False

 d. All the program codes written in switch can be replaced by using if-else.-------False

 19. What is the difference between for loop and while loop?

     for loop is used to execute a group of instructions repeatedly. for loop uses a loop variable to control the number of iterations. 

The syntax of for loop is:

 for(initialisation; test_expression; update_statement)

 { 
statements;
 }

 Here initialisation is used to initialise loop variables. test_expression checks the condition and update statement is used to increment or decrement loop variables.

    while loop is a simple loop that repeatedly execute a group of statements based on a condition.

 The syntax is 

while (test_expression) 


statements;

 } 

Here the test_expression is a condition. The statements inside the loop will be executed as long as the condition remains true.

20. Write the value of the variable y in the following:

 1. x = “welcome”; 
y = x.length;                      Ans. y=7

 2. x = “WELCOME”;
 y = x.toLowerCase();       Ans. y= welcome

3. x = “Welcome”;
 y = x.toUpperCase();        Ans. y = WELCOME

 4. x = “welcome”;
 y = x.toLowerCase();          Ans. y = welcome

 5. x = “welcome”;  
y = isNaN(x);                        Ans. y = True

6. x = “welcome”;
 y = charAt(3);                        Ans. y = c


21. When will onMouseEnter event of JavaScript work?

     Occurs when the mouse pointer is moved onto an object.

 22. The property of the drop-down list  (<SELECT> element) used to get the index of the selected item is __________.

Ans.Selected index

23. Compare onKeyDown and onKeyUp events of JavaScript.

     onKeyDown Occurs when the user is pressing a key on the keyboard and onKeyUp Occurs when the user releases a key on the keyboard.

24. What is the use of Number() function?

       The Number()function converts the data into number type and assigns that number into the variable num1. In the above function, num1 and num2 are treated as number type data and hence the correct result is obtained after adding.

25. What is the advantage of placing JavaScript code just above the </BODY> tag?

    The head section of a web page is loaded before the body section. Therefore, if any function call is made in the body section, the function will be executed as the function definition is already loaded in the memory.

26. 1. Write the value of the variable z in each of the following:

 a. var x, y, z;

 x = 5; y = 3;

z = ++x - y--;                              Ans.  3 

b. var x, y, z;

 x = “12”;

 y = 13;

 z = x + y;                                       Ans. 1213

c. var x, y, z;

 x = 20;

y = 8;

 x %= y;

 z = x++;                                             Ans. 4

 d. var x, y, z;

 x = 1;

 y = 4;

z = !(x < y);                                       Ans. False

e. var x, y, z;

 x = 5;

y = 6 ;

z = (x > y) || (y % 2 == 0);                  Ans. True

27. Write JavaScript functions to perform the following

a. To check whether a variable N contains a number 

 b. To convert the string “scert” to all capitals 

 c. To convert the string “HTML” to all small letters.

d. To display a message “Welcome to functions”.

 e. To display the third character in the string “Computer”.

Answers:-

a.x = N

     y = x. isNaN( );

b.     x = "scert"
       
       y = x.ToUppercase( );

c.    x = "HTML"

        y = x.ToLowercase( );

d.  alert("Welcome to functions");

e.   x = "Computer"

       y = x. charAt( 3 );

28. Classify the following values in JavaScript into suitable data types.
                                     
                                    Answer

 “Welcome” -------------String 

 “123”      -------------- String

 “true”      -------------  String

 67.4       -------------- Number

 .98         --------------  Number

 false     --------------- Boolean

 “hello” -------------- String

30. Explain operators in JavaScript.

        Arithmetic operators,Relational operators,Logical operators,String addition operators and assignment operators.

Arithmetic operator

     +,-,*,/,%,++,-- are the arithmetic operators.

Relational  operators:

          ==,!=,<,<=,>,>= are the relational operators.

Logical operator:

      &&,||,! are the logical operators.

String addition  Operators:

       The same operator + is used to add two strings also. Adding two strings means concatenating two strings. Look at the following example code.

 var x, y;

x = “A good beginning ”;

 y = “makes a good ending.”;

 z = x + y;

 The + operator will add the two strings. Therefore the variable z will have the value A good beginning makes a good ending. The same + operator behaves differently based on the type of operands. If the operands are numbers, it will add the numbers. If the operands are strings it will concatenate the strings.
Now, predict the value of z in the following code:

var x, y;

 x = “23”;

y = 5;

z = x + y;
The answer is 235

Assignment operators

        =,+=,-=,*=,/=,%= are the assignment operators.