3.Advanced Javascript Exercise Solutions

0
नमस्कार विदयार्थी मित्रांनो या पोस्टमध्ये आपण Advanced Javascript Exercise Solutions For Class 12th पाहणारं आहोत. हे Exercise Solutions Maharashtra State Board साठीचे आहेत. या मध्ये आपण पुढील प्रश्न पाहणार आहोत :-
1) Fill in the blanks
2) State whether given statement is true or false
3) Multiple choice questions. Select one correct answer.
4) Multiple choice questions. Select two correct answer.
5) Multiple choice questions. Select three correct answers.
6) Explain the following.
7) Write event driven JavaScript program for following.
8) Match the following.

आता आपण क्रमानुसार प्रश्नांची उत्तरे पाहूया :-


HSC IT - Advanced JavaScript Exercise Solutions Maharashtra Board


Q.1) Fill in the Blanks.


1) _____ script resides on server computer.
Ans : Server Side

2) _____ statement is used to jump out of loop.
Ans : Break

3) _____ defines logical structure of document.
Ans : DOM (Document Object Model)

4) _____ property of window object returns Boolean value indicating whether window is closed or not.
Ans : closed

5) _____ event occurs when an element loses its focus.
Ans : On blue


Q.2) State whether given statement is true or false.


1) JavaScript is case sensitive language.
Ans : True

2) Math.ceil() function is used to return the nearest integer less than or equal to give number.
Ans : False

3) MAX_VALUE property of number object returns smallest possible value.
Ans : False

4) getDay() method of Date object returns month in number.
Ans : False

5) onKeydown event occurs when user moves mouse pointer.
Ans : False

Q.3) Multiple choice questions. Select one correct answer.


1) JavaScript is _____ language.
a) Compiled
b) Interpreted
c) Both a and b
d) None of the above
Ans : c) Both a and b

2) Select correct method name of string object _____.
a) charAt()
b) characterAt()
c) valueAt()
d) lengthAt()
Ans : a) charAt()

3) _____ method displays message box with Ok and Cancel button.
a) Confirm()
b) Alert()
c) both a and b
d) None of these
Ans : a) Confirm()

4) We can declare all types of variables using keyword _____.
a) var
b) dim
c) variable
d) declare
Ans : a) var

5) Trace output of following javascript code.
var str="Information Technology";
document.write(str.lastIndexOf("o");
a) 18
b) 19
c) 20
d) 21
Ans : c) 20

Q.4) Multiple choice questions. Select two correct answer.


1) Valid two methods of Date object are _____ and _____.
a) setTime()
b) getValidTime()
c) getTime()
d) setValidTime()
Ans : a) setTime(), c) getTime()

2) properties of document object are _____ and _____.
a) URL
b) title
c) name
d) status
Ans : a) URL

3) _____ and _____ are event/event handler used with text object in JavaScript.
a) onBlur
b) onMove
c) OnFocus
d) onAction
Ans : a) onBlur, c) onFocus


Q.5) Multiple choice questions. Select three correct answers.


1) Select three correct methods of windows object _____
a) write()
b) alert()
c) writeln()
d) close()
e) open()
f) charAt()
Ans : b) alert(), d) close(), e) open()

2) JavaScript features are _____ , _____ and _____.
a) supports event base facilities
b) is platform dependent language
c) case insensitive scripting language
d) provide inbuilt objects
e) can handle date and time effectively
f) required special software to run
Ans : a) supports event base facilities, d) provide inbuilt objects, e) can handle date and time effectively

3) Inbuilt objects in JavaScript are _____, _____ and _____.
a) Time
b) Date
c) Inheritance
d) Array
e) Number
f) function
Ans : b) Date, d) Array, e) Number


Q.6) Explain the following.


1) What are similarities and differences between client side scripting and server side scripting.
Ans : i) server side scripting is used at the backend where the source code is not visible or hidden at the client side (browser). 
ii)On the other hand, client side scripting is used at the frontend which user can see from the browser.
iii) So server side scripting is more secure than client side scripting.
iv) when a server side script is processed it communication to the server.
v) As against, client-side scripting does not need any server interaction.
vi) The client side scripting language involves language such as HTML5, JavaScript etc.
vii) In contrast, programming languages such as PHP, ASP.net, Ruby, ColdFusion, Python, C# etc. are server side scripting languages.
viii) Server-side scripting is useful in customizing the web pages and implements the dynamic changes in the websites.
ix) Conversely, the client-side scripts are generally used for validation purpose and effectively minimise the load to the server.
x) Special software (web server software) is required to execute server side-script, whereas client side scripts requires web browser as an interface.

2) Briefly explain features of JavaScript.
Ans : i) JavaScript is lightweight scripting language because it does not support all features of object oriented programming languages.
ii) No need of special software to run JavaScript programs.
iii) JavaScript is object oriented scripting language and its supports event base programming facility.
iv) it is case sensitive language.
v) JavaScript helps the browser to perform input validation without wasting the user's time by the web server access.
vi) It can handle date and time effectively.
vii) Most of the JavaScript control statement syntax is same as syntax control statement in other programming languages.
viii) An important part of JavaScript is ability to create new functions within scripts.
ix) Declare a function in JavaScript using function keyword.
x) JavaScript is the platform independent language.

3) Explain switch......case conditional statement in JavaScript with example.
Ans : i) JavaScript has a beauty in multiway deciation statement known as switch.
ii) The switch statement is test the value of given expression against a list of case values and when match is found, a block of statement associated with that case is executed.
iii) There should not be duplicity between the cases.
iv) The value for the case must be similar data types as the variable in switch.
v) The default statement is not mandatory.
vi) Syntax :- switch(expression)
                  {
                      case value1:
                              statement block 1;
                              break;
                      case value2:
                              statement block 2;
                              break;
                      ..................
                      case value n:
                              statement block n;
                              break;
                      default:
                              statement block;
                 }
viii) Program :-
    
<!DOCTYPE html>
<head>
<title> JavaScript Program </title>
</head>
<body>
<h1> Use of Switch case </h1>
<script type="text/javascript">
var day=6;
switch(day)
{
case 1: alert("Monday"); break;
case 2: alert("Tuesday"); break;
case 3: alert("Wednesday"); break;
case 4: alert("Thursday"); break;
case 5: alert("Friday"); break;
case 6: alert("Saturday"); break;
case 7: alert("Sunday"); break;
default: alert("Invalid day");
}
</script>
</body>
</html>

Q.7) Write event driven JavaScript program for the following.


1) Display Addition, Multiplication, Division and remainder of two numbers which were accepted from user.
Ans : i) Program :-
<!DOCTYPE html>
    
<html>
<head>
  <title>Simple Calculator</title>
</head>
<body>
  <h2>Simple Calculator</h2>
  
  <label for="num1">Number 1: </label>
  <input type="number" id="num1">
  <br><br>
  
  <label for="num2">Number 2: </label>
  <input type="number" id="num2">
  <br><br>
  
  <button onclick="calculate()">Calculate</button>
  
  <h3>Results:</h3>
  <p id="addition"></p>
  <p id="multiplication"></p>
  <p id="division"></p>
  <p id="remainder"></p>

  <script>
    function calculate() {
      // Get the values entered by the user
      var num1 = parseInt(document.getElementById("num1").value);
      var num2 = parseInt(document.getElementById("num2").value);
      
      // Perform the calculations
      var addition = num1 + num2;
      var multiplication = num1 * num2;
      var division = num1 / num2;
      var remainder = num1 % num2;
      
      // Display the results
      document.getElementById("addition").innerHTML = "Addition: " + addition;
      document.getElementById("multiplication").innerHTML = "Multiplication: " + multiplication;
      document.getElementById("division").innerHTML = "Division: " + division;
      document.getElementById("remainder").innerHTML = "Remainder: " + remainder;
    }
  </script>
</body>
</html>

ii) Output :- 


2) Display number sequence from 100 to 150 in the following format.
(100 101 102......150)
Ans : i) Program :- 
    
<!DOCTYPE html>
<html>
  <head>
    <title>Number Sequence</title>
  </head>
  <body>
    <div id="sequence"></div>
    <script ref="text/javascript">
    const startNumber = 100;
    const endNumber = 150;
    let sequence = '';
    
    for (let i = startNumber; i <= endNumber; i++) {
    sequence += i + ' ';
    }
    
    document.addEventListener('DOMContentLoaded', () => {
    const sequenceElement = document.getElementById('sequence');
    sequenceElement.textContent = sequence;
    });
    </script>
  </body>
</html>

ii) Output :- 


3) Find and display factorial of given number.
Ans : i) Program :- 
    
<!DOCTYPE html>
<html>
<head>
  <title>Factorial Calculator</title>
  <script>
    function calculateFactorial() {
      var number = parseInt(document.getElementById("numberInput").value);
      var factorial = 1;

      for (var i = 2; i <= number; i++) {
        factorial *= i;
      }

      document.getElementById("result").innerHTML = "Factorial: " + factorial;
    }
  </script>
</head>
<body>
  <h1>Factorial Calculator</h1>
  <label for="numberInput">Enter a number:</label>
  <input type="number" id="numberInput" />
  <button onclick="calculateFactorial()">Calculate</button>
  <p id="result"></p>
</body>
</html>

ii) Output :- 


4) Accept any string from user and count and display number of vowels occurs in it.
Ans : i) Program :- 
    
<!DOCTYPE html>
<html>
<head>
  <title>Vowel Counter</title>
  <script>
    function countVowels() {
      var inputString = document.getElementById("inputString").value;
      var vowelCount = 0;
      var vowels = ['a', 'e', 'i', 'o', 'u'];

      for (var i = 0; i < inputString.length; i++) {
        var currentChar = inputString.charAt(i).toLowerCase();
        if (vowels.includes(currentChar)) {
          vowelCount++;
        }
      }

      document.getElementById("result").innerHTML = "Number of vowels: " + vowelCount;
    }
  </script>
</head>
<body>
  <h1>Vowel Counter</h1>
  <label for="inputString">Enter a string:</label>
  <input type="text" id="inputString" />
  <button onclick="countVowels()">Count</button>
  <p id="result"></p>
</body>
</html>

ii) Output :-


Q.7) Match the following.


         A                                     B
ceil()                    writes HTML expression                                 or JavaScript code to a                                   document.
floor()                  sets focus to current                                       window.
write()                 Remove white spaces                                     from both sides of string.
focus()                Returns next integer                                         greater than or equal to                                 the given number.
trim()                   Returns the next integer                                 less than or equal to give                               number.
Ans : 
ceil() → Returns next integer greater than or equal to the given number.
floor() → Returns the next integer less than or equal to give number.
 write() → Writes HTML expression or JavaScript code to a document.
focus() → Sets focus to current window.
trim() → Remove white spaces from both sides of string.

अशा प्रकारे इयत्ता बारावी Information Technology Chapter No 3 चे Exercise Solutions होते. या Exercise ची PDF Download करण्यासाठीं पुढील लिंक वर क्लिक करा.
यापुढील Chapter चे Exercise Solutions क्रमवार पाहण्यासाठी "Next" आणि "Previous" buttons चा उपयोग करावा.

टिप्पणी पोस्ट करा

0 टिप्पण्या
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
टिप्पणी पोस्ट करा (0)
To Top