IT Practicals Skill Set 2 (Client-Side Scripting JavaScript) Class 11 IT SOP 2 Solutions (इयत्ता ११ वी माहिती तंत्रज्ञान प्रात्यक्षिक – Client-Side Scripting JavaScript SOP 2) — Complete Maharashtra State Board (MSBSHSE) Balbharati practical solutions for FYJC Science, Commerce, and Arts streams, covering the JavaScript Concept Overview, verified Balbharati JavaScript SOP 2 and SOP 1 programs with clean HTML5 source code, execution steps, browser output, practical objective and viva tables, short answers, मराठी टीप, and Exam FAQs.
1. Concept Overview – Client-Side Scripting (JavaScript) for Class 11 IT SOP 2
In the MSBSHSE Balbharati Class 11 Information Technology curriculum, Client-Side Scripting with JavaScript allows web pages to accept user input, evaluate conditions, and render dynamic results in the browser. (In the printed Balbharati manual, JavaScript practicals appear as SOP 1 and SOP 2 under Client-Side Scripting.) Review these core concepts before writing your practical code:
| Concept / Function / Operator | Category | Syntax & Practical Exam Usage |
|---|---|---|
<script> Tag |
HTML Container | Paired tag (<script language="javascript">...</script>) used to embed JavaScript inside <head> or <body>. |
var Keyword |
Variable Declaration | Declares variables (e.g., var num1, num2;). Names are case-sensitive and must begin with a letter or underscore (_). |
prompt() |
Inbuilt Input Function | Displays a browser pop-up input dialog and returns user input as a string. |
parseInt() |
Type Conversion | Converts a string from prompt() into an integer, required for integer divisibility checks. |
parseFloat() / Number() |
Type Conversion | Converts an input string into a positive, negative, or decimal numeric value for accurate comparisons and arithmetic. |
document.write() |
Output Method | Prints text, calculated values, and HTML markup directly onto the browser web page. |
alert() |
Inbuilt Dialog Function | Opens a pop-up message dialog with an OK button to notify the user. |
if ... else if ... else |
Control Structure | Executes specific code blocks based on boolean conditions evaluating to true or false. |
| Arithmetic Operators | +, -, *, /, % |
Perform arithmetic operations; the modulus operator (%) returns the remainder to check multiples of 3 or 7. |
| Comparison Operators | ==, ===, !=, >, < |
Compare values; === verifies strict equality (both value and data type), whereas = assigns values. |
| Logical Operators | &&, ||, ! |
&& (Logical AND) requires both conditions true; || (Logical OR) requires at least one true; ! (NOT) inverts truth. |
| JS Comments | Documentation | // creates a single-line comment and /* ... */ creates a multi-line comment. |
2. Official Balbharati JavaScript Practicals (SOP 2 & SOP 1) – Code & Output
Below are the verified Balbharati Class 11 IT JavaScript practical programs using variables, inbuilt functions (prompt(), parseInt(), parseFloat(), document.write()), and control structures (if...else).
A. Client-Side Scripting (JavaScript) – SOP 2 Problem Statement & Programs
Official Balbharati SOP 2 Problem Statement: Create a JavaScript program for the following using appropriate variables, JavaScript inbuilt functions, and control structures:
- To accept two positive or negative numbers and check whether they are equal or not.
- To accept a number and display the square of it.
- To check whether the accepted integer is a multiple of 3 or a multiple of 7.
SOP 2 – Program 1: Check Whether Two Positive or Negative Numbers Are Equal or Not
This program accepts two numbers via prompt(), converts them using parseFloat() so positive and negative values compare numerically, and checks equality with ===.
<!DOCTYPE html>
<html>
<head>
<title>SOP 2 - Equality Check</title>
</head>
<body>
<h2>Check Whether Two Numbers Are Equal or Not</h2>
<script language="javascript">
var num1, num2;
num1 = parseFloat(prompt("Enter first positive or negative number:"));
num2 = parseFloat(prompt("Enter second positive or negative number:"));
if (num1 === num2) {
document.write("<p>Both numbers (" + num1 + " and " + num2 + ") are Equal.</p>");
} else {
document.write("<p>The numbers (" + num1 + " and " + num2 + ") are Not Equal.</p>");
}
</script>
</body>
</html>
Expected SOP Output: Entering -12 and -12 displays Both numbers (-12 and -12) are Equal. Entering -12 and 12 displays The numbers (-12 and 12) are Not Equal.
SOP 2 – Program 2: Accept a Number and Display the Square of It
This program reads a number using prompt(), converts it via parseFloat(), multiplies it by itself (num * num), and outputs the square with document.write().
<!DOCTYPE html>
<html>
<head>
<title>SOP 2 - Square of a Number</title>
</head>
<body>
<h2>Calculate Square of a Number</h2>
<script language="javascript">
var num, sq;
num = parseFloat(prompt("Enter a number to find its square:"));
sq = num * num;
document.write("<p>The square of " + num + " is: " + sq + "</p>");
</script>
</body>
</html>
Expected SOP Output: Entering 9 displays The square of 9 is: 81; entering -5 displays The square of -5 is: 25.
SOP 2 – Program 3: Check Whether Accepted Integer Is a Multiple of 3 or 7
This program converts the input to an integer with parseInt() and uses the modulus operator (%). Checking n % 3 === 0 && n % 7 === 0 first correctly identifies numbers such as 21 that are divisible by both 3 and 7.
<!DOCTYPE html>
<html>
<head>
<title>SOP 2 - Multiple of 3 or 7</title>
</head>
<body>
<h2>Check Multiple of 3 or Multiple of 7</h2>
<script language="javascript">
var n = parseInt(prompt("Enter an integer:"));
if (n % 3 === 0 && n % 7 === 0) {
document.write("<p>" + n + " is a multiple of both 3 and 7.</p>");
} else if (n % 3 === 0) {
document.write("<p>" + n + " is a multiple of 3.</p>");
} else if (n % 7 === 0) {
document.write("<p>" + n + " is a multiple of 7.</p>");
} else {
document.write("<p>" + n + " is neither a multiple of 3 nor 7.</p>");
}
</script>
</body>
</html>
Expected SOP Output: Input 21 prints 21 is a multiple of both 3 and 7.; input 12 prints 12 is a multiple of 3.; input 14 prints 14 is a multiple of 7.; input 10 prints 10 is neither a multiple of 3 nor 7.
B. Client-Side Scripting (JavaScript) – SOP 1 Combined Reference
Official Balbharati SOP 1 Tasks: (1) Multiply an integer by 3, (2) display the larger of two integers, and (3) check if a number is positive or negative:
<!DOCTYPE html>
<html>
<head>
<title>Class 11 IT - JavaScript SOP 1</title>
</head>
<body>
<h2>JavaScript Practical - SOP 1</h2>
<script language="javascript">
// 1. Multiply integer by 3
var m = parseInt(prompt("Enter an integer to multiply by 3:"));
document.write("<p><b>1. Result (x3):</b> " + (m * 3) + "</p>");
// 2. Larger of two integers
var x = parseInt(prompt("Enter first integer:"));
var y = parseInt(prompt("Enter second integer:"));
if (x > y) {
document.write("<p><b>2. Larger Number:</b> " + x + "</p>");
} else if (y > x) {
document.write("<p><b>2. Larger Number:</b> " + y + "</p>");
} else {
document.write("<p><b>2. Larger Number:</b> Both are equal.</p>");
}
// 3. Positive or negative check
var p = parseFloat(prompt("Enter a number to check positive or negative:"));
if (p > 0) {
document.write("<p><b>3. Sign:</b> " + p + " is Positive.</p>");
} else if (p < 0) {
document.write("<p><b>3. Sign:</b> " + p + " is Negative.</p>");
} else {
document.write("<p><b>3. Sign:</b> Zero.</p>");
}
</script>
</body>
</html>
C. Step-by-Step Practical Execution Procedure (SOP Steps)
- Open a plain text editor such as Notepad (Windows) or gedit (Linux).
- Type the complete HTML5 document containing the
<script>...</script>block. - Save the file using Save As → All Files with a
.htmlextension (for example,sop2.html). - Double-click the saved
.htmlfile to run it in Google Chrome, Microsoft Edge, or Mozilla Firefox (click Allow Blocked Content if prompted). - Enter sample positive, negative, zero, and multiple-of-3/7 inputs in the
prompt()boxes to verify thedocument.write()output.
3. Practical Viva & Exam Practice Questions – Class 11 IT SOP 2
Balbharati practical SOP units are evaluated through coding, browser output, and viva/online objective questions grounded in the JavaScript methods and operators above.
A. Fill in the Blanks (Practical Objective Practice)
| No. | Question Statement | Correct Answer |
|---|---|---|
| 1 | The ________ function displays a browser dialog box to accept user input as a string. | prompt() |
| 2 | The ________ function converts an input string into an integer value in JavaScript. | parseInt() |
| 3 | The ________ method writes output text or HTML directly onto the web page. | document.write() |
| 4 | The ________ operator returns the remainder of a division operation to check multiples of 3 or 7. | modulus (%) |
| 5 | JavaScript code is placed inside an HTML page using the ________ container tag. | <script>...</script> |
| 6 | An HTML file containing JavaScript SOP code must be saved with the ________ extension. | .html (or .htm) |
B. State Whether the Following Statements Are True or False
| No. | Statement | Answer & Reason |
|---|---|---|
| 1 | The prompt() function returns user input as a string data type by default. |
True. Numeric conversion via parseInt(), parseFloat(), or Number() is needed for math or comparisons. |
| 2 | In JavaScript, the single equals sign (=) checks whether two numbers are equal. |
False. = is the assignment operator; equality uses == or strict equality ===. |
| 3 | If num % 3 === 0 is true, then num is divisible by 3. |
True. A zero remainder confirms the integer is a multiple of 3. |
| 4 | A JavaScript variable name can start with a digit, such as 2num. |
False. Variable names must start with a letter, underscore (_), or dollar sign, never a digit. |
| 5 | JavaScript files must be compiled into machine code before running in a browser. | False. JavaScript is an interpreted client-side scripting language executed directly by the browser. |
C. Multiple Choice Questions (MCQ1, MCQ2 & MCQ3)
| Type | Question & Options | Correct Option(s) & Explanation |
|---|---|---|
| MCQ1 | Which function converts a decimal string into a floating-point number? (A) parseFloat() (B) document.write() (C) alert() (D) prompt() |
(A) parseFloat()It parses a string and returns a floating-point number. |
| MCQ1 | Which expression checks if integer n is a multiple of 3 or 7?(A) n / 3 == 0 || n / 7 == 0 (B) n % 3 === 0 || n % 7 === 0 (C) n * 3 === 0 (D) n = 3 || 7 |
(B) n % 3 === 0 || n % 7 === 0The modulus operator % tests if the remainder equals 0. |
| MCQ1 | What is the value of num * num when num equals -8?(A) -64 (B) -16 (C) 64 (D) 16 |
(C) 64Multiplying two negative numbers produces a positive square. |
| MCQ2 | Which two functions convert a string from prompt() into a number?(A) parseInt() (B) document.write() (C) parseFloat() (D) alert() |
(A) parseInt() and (C) parseFloat()Both convert text input into integer or decimal numbers. |
| MCQ2 | Which two logical operators are valid in JavaScript? (A) && (B) AND (C) || (D) OR |
(A) && and (C) ||&& is Logical AND and || is Logical OR. |
| MCQ3 | Which three statements are true about JavaScript in Class 11 IT SOPs? (A) Runs inside a browser (B) prompt() reads user input (C) % finds remainder (D) Saved as .exe (E) Variables can start with digits |
(A), (B), and (C) JavaScript executes in browsers, accepts input via prompt(), and checks remainders using %. |
D. Match the Following (JavaScript Elements & Purpose)
| Column A (Element) | Column B (Purpose in SOP 2) |
|---|---|
1. prompt() |
Accepts user input via a browser dialog box |
2. parseInt() |
Converts an input string into an integer |
3. document.write() |
Displays output directly on the web page |
4. === |
Checks strict equality (value and type) |
5. % (Modulus) |
Finds the remainder to test multiples of 3 or 7 |
6. if ... else |
Controls conditional branching in JavaScript |
E. Answer the Following Questions in Brief (Viva & Exam Answers)
1. Why should parseInt() or parseFloat() be used with prompt()?
prompt()always returns user input as a string, even when digits are entered.- Using
+on strings causes concatenation (e.g.,"5" + "3"yields"53"instead of8). parseInt()andparseFloat()convert strings into numbers so arithmetic and comparisons work accurately.
2. How does the modulus operator (%) check whether an integer is a multiple of 3 or 7?
- The
%operator returns the remainder after integer division. n % 3 === 0confirms divisibility by 3, andn % 7 === 0confirms divisibility by 7.- Testing
n % 3 === 0 && n % 7 === 0first handles numbers like21that are multiples of both.
3. Differentiate between =, ==, and === in JavaScript.
=(Assignment): Assigns a value to a variable (var x = 10;).==(Loose Equality): Compares values after automatic type conversion.===(Strict Equality): Checks that both value and data type match without implicit conversion.
4. State the difference between document.write() and alert().
document.write()writes formatted HTML output directly onto the browser page.alert()displays a plain-text pop-up message box with an OK button.
4. मराठी टीप (Marathi Practical & Exam Revision Tip)
मराठी टीप: इयत्ता ११ वी IT प्रात्यक्षिक (Client-Side Scripting JavaScript – SOP 2) साठी या ५ गोष्टी लक्षात ठेवा — (१) फाईल नेहमी .html extension ने save करा (उदा. sop2.html); (२) prompt() ने घेतलेली किंमत String असते, म्हणून गणितापूर्वी parseInt() किंवा parseFloat() वापरा; (३) समानता तपासण्यासाठी = ऐवजी === वापरा; (४) ३ किंवा ७ च्या पटीतील संख्या तपासण्यासाठी % (Modulus) operator वापरून 21 सारख्या संख्येसाठी && ची अट आधी तपासा; (५) Chrome किंवा Edge browser मध्ये output verify करा.
Frequently Asked Questions – Class 11 IT SOP 2
Q.1 Which three JavaScript programs are included in Class 11 IT Client-Side Scripting SOP 2?
As per the MSBSHSE Balbharati Class 11 IT practical syllabus, JavaScript SOP 2 covers three tasks: (1) checking whether two positive or negative numbers are equal or not, (2) accepting a number and displaying its square, and (3) checking whether an accepted integer is a multiple of 3 or a multiple of 7.
Q.2 Why does prompt() require parseInt() or parseFloat() before calculations?
Because prompt() returns text as a string, converting the input with parseInt() (integers) or parseFloat() (positive, negative, or decimal numbers) prevents string concatenation errors and ensures accurate numeric comparisons.
Q.3 How do you save and execute a Class 11 IT JavaScript SOP file in the practical exam?
Write the HTML5 and <script> code in Notepad, save it using Save As → All Files as sop2.html, and open it in Google Chrome or Microsoft Edge to enter inputs in the prompt() pop-ups and view the document.write() output.