Anjeev Singh Academy

Anjeev Singh Academy

Class 12 Web Application 803 CBSE Previous Year JavaScript Question Answer 2020 (New)

Previous Year CBSE Board Question Paper 2022-2017

CLASS XII WEB APPLICATION (SUBJECT CODE -803)

CHAPTER 3- WEB SCRIPTING – JAVASCRIPT

Answer Key of Previous Year Questions | CBSE Year 2020 (New) Examination

1 – Mark Questions

1. JavaScript was developed by

(A) Brendan Eich

(B) Dennis Ritchie

(C) Robert Hooke

Answer: (A) Brendan Eich

2. Variables in JavaScript can be declared using

(A) VAR

(B) Var

(C) var

(D) Dim

Answer: (C) var

3. % in JavaScript is an example of

(A) Arithmetic operator

(B) Relational operator

(C) Bitwise shift operator

(D) Unary operator

Answer: (A) Arithmetic Operator

4. Numbers in JavaScript are double-precision

(A) 32-bit format

(B) 128-bit format

(C) 64-bit format

(D) 16-bit format

Answer: 64-bit format

2 – Marks Questions

5. Give any two tips to remember while writing JavaScript commands.

Answer: Tips to remember when writing JavaScript commands.

  • JavaScript code is case sensitive
  • White space between words and tabs are ignored
  • Line breaks are ignored except within a statement
  • JavaScript statements end with a semi- colon;

6. Write the output of the given code:

<html>

<body>

<script>

 s= [“blue”, “red”, “orange”, “yellow”]

 s.reverse();

 for (i=0; i <s.length; i = i +2)

 document.write(s[i].toUpperCase() + “<br>”);                    

</script>

</body>

</html>

Answer: Output is

          YELLOW

          RED

3 – Marks Questions

7. Give and explain any three applications of JavaScript.

Answer: Applications of JavaScript are

(a) Developing Multimedia Applications: The users can use JavaScript to add multimedia elements. With JavaScript you can show, hide, change, resize images and create images rollovers. You can create scrolling text across the status bar, thus making multimedia applications more interactive.

(b) Create Pages Dynamically: Based on the user’s choice, the date or other external data, JavaScript can produce pages that are customized to the user.

(c) Interact with the User: JavaScript can do some processing of forms and can validate user input when the user submits the form.

8. Write a code in JavaScript that accepts a binary number from the user and displays its decimal equivalent number.

Answer:

<HTML>
<head>
<title>Binary to Decimal </title>
</head>
<body>
<script type=”text/javascript”>
var binary = prompt(“Enter a binary number “);
var decimal = parseInt(binary, 2);
document.write(“Binary Number : “+ binary + “<be>”);
document.write(“Decimal Number: “+ decimal  + “<be>”);
</script>      
</body>
</html>

Output:

Binary Number : 101001
Decimal Number: 41

9. Write a code in JavaScript to accept five numbers from user, store them in an array, and display the sorted array.

Answer:

<script type=”text/javascript”>

var num = new Array(5);

for(var i = 0; i < 5; i++)

{

     x = parseInt(prompt(“Number “+(i+1)));

     num[i] = x

}

num.sort();

document.write(“Sorted Array” + “<br>”);

for(var i = 0; i < 5; i++)

{

     document.write(num[i] + “<br>”);

}

</script>

Output:

Sorted Array
3
4
6
8
9

5 – Marks Questions

10. Write a code in JavaScript to accept a number from the user and generate

     (a) a random number greater than the number entered.

     (b) next even number after the number entered

Answer:

<script type=”text/javascript”>

x = parseInt(prompt(“Enter a Number “));

var num = Math.round(x + Math.random() * x)

document.write(“Random Number greater than ” + x + ” is ” + num + “<br>”);

var even = 0;

if (x % 2 == 0)

            even = x + 2;

else

            even = x + 1

document.write(“Next Even Number, after ” +x + ” is “+ even + “<br>”)

</script>  

11. Write a program in JavaScript to accept marks in three subjects, display the total marks obtained, the percentage, and the grade as per the norms given below:

PercentageGrade
>= 75
< 75 and >= 60
< 60 and >= 33
< 33
A
B
C
D

Answer:

<HTML>
<head>
<title>PROGRAM</title>
</head>
<body>
<script type=”text/javascript”>
          x = parseInt(prompt(“Marks 1 “));
          y = parseInt(prompt(“Marks 2 “));
          z = parseInt(prompt(“Marks 3 “));
          total = x  + y + z;
          percentage = total / 300 * 100;
          document.write(“Marks 1 : ” +x + “<be>”);
          document.write(“Marks 2 : ” +y + “<be>”);
          document.write(“Marks 3 : ” +z + “<be>”);
          document.write(“Total Marks :”+total+ “<be>”);
          document.write(“Percentage : ” +Math.round(percentage)+”%”+ “<be>”);
          var grade=” “;
          if (percentage >=75)
                   grade = “A”;
          else if (percentage >= 60 && percentage < 75)
                   grade = “B”;
          else if (percentage >= 33 && percentage < 60)
                   grade = “C”;
          else
                   grade = “D”;
          document.write(“Grade : ” + grade + “<be>”);
     </script>
</body>
</html>

12. What may be the possible output of the following snippets:

(a) Predict the output of the following:

<html>

<body>

<script>

var fruits = [“Apple”, “mango”];

fruits[50]= “Orange”;

document.write(fruits.length);

document.write(“<br> end of program”);

</script>

</body>

</html>

Answer: Output is

51

end of program

(b) Rewrite the following using switch case statement:

if(a==1)

            document.write(“Monday, Wednesday, Friday”);

else if(a==2)

            document.write(“Tuesday, Thursday, Saturday”);

else

            document.write(“Sunday”)

Answer:

switch(a)

{

case 1:

            document.write(“Monday, Wednesday, Friday”);

            break;

case 2:

            document.write(“Tuesday, Thursday, Saturday”);

            break;

default:

            document.write(“Sunday”)

            break;

}

Sorry! You cannot copy content of this page. Please contact, in case you want this content.

Scroll to Top