Advanced JavaScript Class 12 IT (Science) Chapter 3 Question Answer | महाराष्ट्र बोर्ड स्वाध्याय

Master Advanced JavaScript Class 12 IT (Science) Chapter 3 with complete, latest-syllabus-verified Maharashtra State Board (MSBSHSE) Balbharati exercise solutions. This comprehensive study guide covers all textbook questions—including Fill in the Blanks, True or False, Multiple Choice Questions (MCQs), and Short Answers—along with board-exam-style 2-correct and 3-correct MCQs, Match the Following, built-in JavaScript objects, DOM event handling, and fully solved HTML5 + JavaScript programs.

Key JavaScript Objects, DOM Properties, and Events – Chapter 3 Overview

Advanced JavaScript extends basic client-side scripting by introducing control flow statements, user-defined functions, the Document Object Model (DOM), Browser Object Model (Window object), event-driven programming, and built-in objects such as String, Math, Date, Number, and Array. Before solving the Balbharati textbook exercise, review the essential JavaScript keywords, methods, properties, and event handlers tested in the Class 12 IT Science board examination.

JavaScript Element / Method Object / Category Purpose & Board Exam Significance
var / let Variable Declaration var declares variables of any data type (string, number, boolean) dynamically because JavaScript is loosely typed.
switch, break, continue Control Statements switch handles multiway branching; break exits a loop immediately; continue skips the current iteration and moves to the next.
for, while, do...while Looping Statements Repeat a block of statements. do...while is exit-controlled and executes the loop body at least once before checking the condition.
document.getElementById() & innerHTML DOM (Document Object Model) Selects an HTML element by its unique id attribute and dynamically reads or updates its HTML content.
alert(), confirm(), prompt() window Object Methods alert() shows an OK message box; confirm() shows OK and Cancel returning a boolean; prompt() collects user text input.
closed property window Object Property Returns a Boolean value (true or false) indicating whether a browser window has been closed.
charAt(), indexOf(), lastIndexOf() String Object Methods charAt() returns the character at a given index; indexOf() and lastIndexOf() locate first and last character positions (case-sensitive).
Math.ceil(), Math.floor(), Math.round() Math Object Methods ceil() rounds up, floor() rounds down, and round() rounds to the nearest integer.
getDay(), getMonth(), getFullYear() Date Object Methods getDay() returns weekday index (0–6); getMonth() returns month index (0–11); getFullYear() returns the 4-digit year.
MAX_VALUE, MIN_VALUE Number Object Properties Number.MAX_VALUE returns the largest representable number in JavaScript, while Number.MIN_VALUE returns the smallest positive number.
onfocus, onblur, onchange Form & Input Events onfocus fires when an element gains focus; onblur fires when it loses focus; onchange fires when its value changes.
onkeydown, onkeyup, onclick Keyboard & Mouse Events onkeydown and onkeyup respond to keyboard presses; onclick triggers when a user clicks an element.

Balbharati Textbook Exercise Solutions – Chapter 3: Advanced JavaScript

Below are the complete, accurate solutions to the objective and descriptive exercise questions from Chapter 3 of the Maharashtra State Board Class 12 Information Technology (Science) Balbharati curriculum.

Q.1. Fill in the Blanks

Q. No. Textbook Statement Correct Answer
1 _________________ script resides on server computer. Server-side
2 _________________ statement is used to jump out of a loop. break
3 _________________ defines the logical structure of documents. DOM (Document Object Model)
4 The _________________ property returns a Boolean value indicating whether a window has been closed or not. closed
5 _________________ event occurs when an element loses its focus. onblur

Q.2. State Whether the Following Statements Are True or False

Q. No. Textbook Statement Answer & Reason
1 JavaScript is a case-sensitive language. True — Keywords, variables, and function names distinguish between uppercase and lowercase letters (for example, myVar and myvar are treated as different identifiers).
2 MAX_VALUE property of Number object returns the smallest possible value. False — Number.MAX_VALUE returns the largest possible numeric value in JavaScript; Number.MIN_VALUE returns the smallest positive value.
3 getDay() method of Date object returns the month in number. False — getDay() returns the day of the week (0 for Sunday through 6 for Saturday); getMonth() returns the month index (0–11).
4 onkeydown event occurs when the user moves the mouse pointer. False — onkeydown occurs when a keyboard key is pressed down; mouse pointer movement triggers onmousemove or onmouseover.

Q.3. Multiple Choice Questions (Select One Correct Answer)

Q. No. Textbook Question Correct Option Explanation
1 JavaScript is a _________ language.
a) Compiled   b) Interpreted   c) Machine   d) Assembly
b) Interpreted JavaScript code is executed line by line directly inside the web browser’s JavaScript engine without separate prior compilation.
2 Select correct method name of String object:
a) charAt()   b) floor()   c) getDate()   d) alert()
a) charAt() charAt() belongs to the String object and returns the character at a specified index; floor() is in Math, getDate() in Date, and alert() in window.
3 _________ method displays a message box with OK and Cancel buttons.
a) confirm()   b) alert()   c) prompt()   d) write()
a) confirm() window.confirm() opens a modal dialog with OK and Cancel buttons and returns true if OK is clicked or false if Cancel is clicked.
4 We can declare all types of variables using keyword:
a) var   b) int   c) float   d) char
a) var JavaScript uses dynamic typing, so var (as well as let/const) can store numbers, strings, booleans, or objects without explicit type keywords.
5 Trace output of the following JavaScript code:
var str = "INFORMATION Technology";
document.write(str.lastIndexOf("O"));
a) 18   b) 19   c) 9   d) 20
c) 9 (Note: Textbook key often prints b) 19 for lowercase "o") Because JavaScript strings are zero-indexed and case-sensitive, uppercase "O" last appears at index 9 (in INFORMATION), whereas lowercase "o" in Technology sits at index 19. Always verify character case in board exam tracing questions.

Board Exam Practice: Multi-Select MCQs, True/False & Match the Following

In the MSBSHSE Class 12 IT online board examination, students also encounter Two-Correct MCQs, Three-Correct MCQs, Match the Following, and extra Fill in the Blanks / True or False items from Advanced JavaScript. Practice the syllabus-aligned sets below to prepare for every exam pattern.

Practice Set A: Fill in the Blanks & True/False (Syllabus Practice)

Format Practice Question Answer & Explanation
Fill in the Blank JavaScript has a built-in multiway decision statement known as _________. switch — Evaluates an expression and executes the matching case block.
Fill in the Blank The _________ statement skips the remaining code in the current loop iteration and jumps to the next iteration. continue — Unlike break, continue does not exit the loop entirely.
Fill in the Blank The _________ keyword is used to create a new instance of an object in JavaScript. new — For example, var d = new Date();.
Fill in the Blank The _________ object is the top-level parent object of all browser objects in the hierarchy. window — Properties like document, location, and history reside inside window.
True / False JavaScript cannot handle date and time operations. False — JavaScript provides the built-in Date object for reading and manipulating dates and times.
True / False Properties and methods of an object are accessed using the dot (.) operator. True — Example: str.length or Math.sqrt(25).
True / False The toLowerCase() method converts a given string into uppercase letters. False — toLowerCase() converts characters to lowercase; toUpperCase() converts to uppercase.

Practice Set B: MCQs with Two and Three Correct Options

Question Type Question Statement Correct Answers & Justification
MCQ (2 Correct) Which two statements are true about Client-Side JavaScript?
a) It executes directly on the user’s web browser
b) It requires a server round-trip for every button click
c) It is commonly used for form validation and interactive UI effects
d) It directly connects to MySQL databases without a backend
a) and c) — Client-side JavaScript runs locally inside the browser, reducing server load by validating forms and updating UI elements immediately.
MCQ (2 Correct) Which two methods belong to the JavaScript window object for displaying dialog boxes?
a) alert()
b) charAt()
c) confirm()
d) toUpperCase()
a) and c) — alert() and confirm() (along with prompt()) are standard window dialog methods; charAt() and toUpperCase() are String methods.
MCQ (3 Correct) Select three valid built-in objects in JavaScript:
a) String
b) Math
c) Integer
d) Date
e) Float
a), b), and d) — String, Math, and Date are core built-in JavaScript objects; JavaScript uses Number rather than separate Integer or Float objects.
MCQ (3 Correct) Which three are valid JavaScript event handlers used with HTML elements?
a) onfocus
b) onblur
c) onprintscreen
d) onclick
e) oncompile
a), b), and d) — onfocus, onblur, and onclick are standard DOM/form event handlers triggered by focus changes and mouse clicks.

Practice Set C: Match the Following & Statement Rearranging

Column A Column B (Jumbled) Correct Match
1. do...while loop a) Locates first occurrence of a substring 1 → c) Executes body at least once
2. indexOf() b) Rounds a number down to nearest integer 2 → a) Locates first occurrence of a substring
3. Math.floor() c) Executes body at least once 3 → b) Rounds a number down to nearest integer
4. onfocus event d) Fires when an input control becomes active 4 → d) Fires when an input control becomes active

Q.4. Short Answer Solutions – Class 12 IT Chapter 3

Write crisp, point-wise answers in your board examination to score full marks. Below are complete, syllabus-aligned solutions to the core descriptive questions in Chapter 3.

1. What are the similarities and differences between Client-Side Scripting and Server-Side Scripting?

Answer:

Similarities: Both client-side and server-side scripting use programming logic (variables, conditions, loops, and functions) to make web pages interactive, dynamic, and responsive to user actions.

Differences:

Basis of Comparison Client-Side Scripting Server-Side Scripting
Execution Location Executes locally on the user’s web browser (client computer). Executes on the remote web server before sending output to the browser.
Primary Purpose Used for input form validation, UI animations, DOM manipulation, and instant user feedback. Used for database connectivity, secure login authentication, session handling, and backend processing.
Code Visibility Source code is visible to the user via browser Developer Tools or “View Source”. Source code remains hidden on the server; only generated HTML output reaches the browser.
Server Load & Speed Reduces server load and responds immediately without waiting for network round-trips. Requires server resources and network communication for every request.
Common Examples JavaScript, HTML5/CSS3 interactions. PHP, Node.js, Python, ASP.NET, JSP.

2. Explain briefly the features of JavaScript.

Answer:

  • Lightweight & Interpreted Language: JavaScript is compact and executed directly by the browser without needing heavy compilation steps.
  • Object-Based / Object-Oriented Support: It provides built-in objects like String, Math, Date, Number, and Array, and allows developers to create user-defined objects.
  • Case-Sensitive: Identifiers, keywords, and method names differentiate between uppercase and lowercase characters (e.g., getElementById must match exact camelCase).
  • Platform Independent: Any standard modern browser on Windows, Linux, macOS, or mobile operating systems can execute JavaScript uniformly.
  • Event-Driven & Client-Side Validation: Supports event handlers (onclick, onblur, onchange, onsubmit) to validate form inputs before sending data to the server.
  • Dynamic Typing: Variables declared with var or let can hold any data type without strict static type declarations.

3. Explain the Document Object Model (DOM) and Window Object in JavaScript.

Answer:

  • Window Object: The window object sits at the top of the browser object hierarchy and represents an open browser window or tab. It provides dialog methods such as alert(), confirm(), and prompt(), timing methods like setTimeout(), and properties such as closed and document.
  • Document Object Model (DOM): When a browser loads an HTML webpage, it builds a tree-like logical representation of all HTML elements called the DOM. Using methods like document.getElementById() and properties like innerHTML or style, JavaScript can dynamically read, modify, add, or delete page content and styles without reloading the page.

Solved JavaScript & HTML5 Programs (SOP & Coding Solutions)

Board practicals (SOPs) and coding questions in Class 12 IT Chapter 3 test loops, user-defined functions, string/math operations, event handling, and form validation. Study the clean, properly escaped HTML5 + JavaScript programs below.

Program 1: Calculate Factorial of a Number Using a Function & Loop

This program accepts a non-negative integer from the user via an HTML input field and displays its factorial inside a paragraph using DOM manipulation.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Factorial Calculator in JavaScript</title>
  <script>
    function findFactorial() {
      var n = parseInt(document.getElementById("num").value, 10);
      var output = document.getElementById("result");

      if (isNaN(n) || n < 0) {
        output.innerHTML = "Please enter a valid non-negative integer.";
        return;
      }

      var fact = 1;
      for (var i = 1; i <= n; i++) {
        fact = fact * i;
      }
      output.innerHTML = "Factorial of " + n + " is " + fact;
    }
  </script>
</head>
<body>
  <h2>Factorial Program</h2>
  <label for="num">Enter Number:</label>
  <input type="number" id="num" min="0">
  <button type="button" onclick="findFactorial()">Calculate Factorial</button>
  <p id="result"></p>
</body>
</html>

Program 2: Count Vowels in a Given String Using String Object Methods

This SOP-style program takes a string input and uses toLowerCase(), length, and charAt() in a for loop to count total vowels.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Count Vowels in String</title>
  <script>
    function countVowels() {
      var text = document.getElementById("txt").value.toLowerCase();
      var count = 0;

      for (var i = 0; i < text.length; i++) {
        var ch = text.charAt(i);
        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
          count++;
        }
      }
      document.getElementById("vowelOutput").innerHTML = "Total Vowels: " + count;
    }
  </script>
</head>
<body>
  <h2>Vowel Counter</h2>
  <input type="text" id="txt" placeholder="Enter any word or sentence">
  <button type="button" onclick="countVowels()">Count Vowels</button>
  <p id="vowelOutput"></p>
</body>
</html>

Program 3: Client-Side Form Validation Using onsubmit & Event Handlers

This program demonstrates client-side validation for Name, Email, and 10-digit Mobile Number using JavaScript conditional checks and alert().

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>JavaScript Form Validation</title>
  <script>
    function validateForm() {
      var name = document.getElementById("sname").value.trim();
      var email = document.getElementById("semail").value.trim();
      var mobile = document.getElementById("smobile").value.trim();

      if (name == "") {
        alert("Student name cannot be empty.");
        return false;
      }
      if (email.indexOf("@") == -1 || email.indexOf(".") == -1) {
        alert("Please enter a valid email address.");
        return false;
      }
      if (mobile.length != 10 || isNaN(mobile)) {
        alert("Please enter a valid 10-digit mobile number.");
        return false;
      }
      alert("Form validated successfully!");
      return true;
    }
  </script>
</head>
<body>
  <h2>Student Registration Form</h2>
  <form onsubmit="return validateForm()">
    Name: <input type="text" id="sname"><br><br>
    Email: <input type="text" id="semail"><br><br>
    Mobile: <input type="text" id="smobile"><br><br>
    <input type="submit" value="Submit">
  </form>
</body>
</html>

Program 4: Background Color Changer Using DOM & Mouse Events

This short program illustrates event-driven DOM updates using onmouseover and onmouseout on a button element.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>DOM Mouse Event Example</title>
  <script>
    function setColor(bg) {
      document.body.style.backgroundColor = bg;
    }
  </script>
</head>
<body>
  <h2>Hover Over the Buttons to Change Background</h2>
  <button type="button" onmouseover="setColor('lightyellow')" onmouseout="setColor('white')">Yellow Theme</button>
  <button type="button" onmouseover="setColor('lightblue')" onmouseout="setColor('white')">Blue Theme</button>
</body>
</html>

Frequently Asked Questions – Science Ch 3 Advanced JavaScript

What is the difference between break and continue statements in JavaScript?

The break statement immediately terminates the enclosing loop (for, while, or do...while) or switch block and transfers control to the statement following the loop. In contrast, the continue statement skips only the remaining statements in the current iteration and jumps to the next iteration of the loop.

How does getDay() differ from getDate() in the JavaScript Date object?

The getDay() method returns the day of the week as an integer from 0 (Sunday) to 6 (Saturday). On the other hand, getDate() returns the day of the month as an integer from 1 to 31.

Why is client-side form validation important in Advanced JavaScript?

Client-side validation checks user inputs (such as empty fields, email formatting, or numeric ranges) directly inside the browser before submitting the form to a server. This gives users instant error feedback, prevents invalid requests, reduces network bandwidth usage, and lowers server processing load.

Telegram group मध्ये जॉईन व्हा

Leave a Comment