0% found this document useful (0 votes)
17 views103 pages

Operating System Model Answers 2024

The document provides a model answer for the Operating System subject for the Summer 2024 examination by the Maharashtra State Board of Technical Education. It includes important instructions for examiners on how to assess student answers, a list of questions with their corresponding model answers, and explanations of key concepts such as resource management, process scheduling, and interprocess communication. The document emphasizes flexibility in grading based on understanding rather than strict adherence to model answers.

Uploaded by

Ayush Jagtap
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views103 pages

Operating System Model Answers 2024

The document provides a model answer for the Operating System subject for the Summer 2024 examination by the Maharashtra State Board of Technical Education. It includes important instructions for examiners on how to assess student answers, a list of questions with their corresponding model answers, and explanations of key concepts such as resource management, process scheduling, and interprocess communication. The document emphasizes flexibility in grading based on understanding rather than strict adherence to model answers.

Uploaded by

Ayush Jagtap
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Important Instructions to examiners:


1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may
try to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in
the figure. The figures drawn by candidate and model answer may vary. The examiner
may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constant values may vary and there may be some difference in the candidate’s answers
and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of
relevant answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi
and Bilingual (English + Marathi) medium is introduced at first year of AICTE diploma
Programme from academic year 2021-2022. Hence if the students in first year (first and
second semesters) write answers in Marathi or bilingual language (English +Marathi), the
Examiner shall consider the same and assess the answer based on matching of concepts
with model answer.

Q. Sub Answer Marking


No Q.N. Scheme
1. Attempt any FIVE of the following: 10
a) List different types of operating system 2M
Ans.  Batch Operating System
 Multi-ProgrammingOperating System Any four
types 1/2M
 Time Shared Operating System each
 Multiprocessor System
 Distributed System
 Real Time Operating System
 Mobile Operating System
b) State any four services provided by an operating system 2M
Ans.  User Interface Any four
services
 Program Execution
1/2M each
 I/O Operation

Page 1 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

 File System Manipulation


 Communication
 Error Detection
 Resource Allocation
 Accounting
 Protection and Security
c) Draw process state diagram 2M
Ans.
Correct
diagram 2M

d) State two features of non-preemptive scheduling 2M


Ans.  Once CPU is allocated to the process, the process keeps the CPU
until it releases the CPU either by terminating or by switching to Any two
the waiting state. relevant
features 1M
 A process switches from running state to waiting state or running to each
terminated state.
 Low scheduling overhead.
 Simple to implement and manage.
 Less responsive in terms of priority for urgent task.
e) Define following terms: 2M
i. Memory compaction
ii. Fragmentation Correct
Ans. i. Memory compaction: definition
1M each
The process of shuffling the memory contents so as to place all free
memory together in one large block is known as memory compaction.

ii. Fragmentation:
When processes are loaded and removed from memory, the free
memory space is broken into little pieces which is known as
fragmentation.

Page 2 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

f) Write syntax of PWD command and explain its use with the help 2M
of suitable example.
Ans. Syntax: $ pwd
PWD command is used to print (display) current working directory. Syntax 1M

Use &
Example: $ pwd example 1M
Above example displays absolute pathname.
Output: /home/poly
g) List any four file operations. 2M
Ans.  Creating a file
 Writing a file Any four
operations
 Reading a file 1/2M each
 Repositioning within a file
 Deleting a file
 Appending new information to the end of the file
 Renaming an existing file.
 Truncating a file
 Creating copy of a file, copy file to another I/O device such as
printer or display
2. Attempt any THREE of the following: 12
a) Explain Resource management of an operating system. 4M
Ans.  Resource Management in Operating System is the process to
manage all the resources efficiently like CPU, memory, Any
relevant
input/output devices, and other hardware resources among the explanation
various programs and processes running in the computer. 4M
 Computer's resources are limited and several users or programs
may need to utilize the same resources—such as memory and
CPU—at the same time.
 Operating system has to manage and ensure that all processes get
the resources they need to execute, without any problems like
deadlocks.
 Operating systems use various scheduling algorithms to ensure
that each process gets its fair share of CPU time.
 Operating systems use virtual memory techniques to manage
memory efficiently.
 Operating systems use file system management techniques to
manage disk space efficiently.
 File system management allows the operating system to create,

Page 3 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

delete, and modify files and directories in Secondary Storage


Device.
 Operating systems use various network management techniques to
manage network bandwidth efficiently.
b) Explain different components of operating system. 4M
Ans. List of System Components:
1. Process Management Any two
2. Main Memory Management components
with
3. File Management relevant
4. I/O System Management explanation
5. Secondary Storage Management 2M each

1. Process Management:
A program is a set of instructions. When CPU is allocated to a
program, it can start its execution. A program in execution is a
process. A word processing program run by a user on a PC is a
process. A process needs various system resources including CPU
time, memory, files and I/O devices to complete the job execution.
These resources can be given to the process when it is created or
allocated to it while it is running.
The operating system responsible for the following activities in
connection with process management:
 Creation and deletion of user and system processes.
 Suspension and resumption of processes.
 A mechanism for process synchronization.
 A mechanism for process communication.
 A mechanism for deadlock handling.

2. Main-Memory Management
Main memory is a large array of words or bytes, ranging in size from
hundreds of thousands to billions. Each word or byte has its own
address. Main memory is a repository of quickly accessible data
shared by the CPU and I/O devices. The central processor reads
instructions from main memory during the instruction fetch cycle and
both reads and writes data from main memory during the data fetch
cycle. The main memory is generally the only large storage device
that the CPU is able to address and access directly.
The operating system responsible for the following activities in
connection with main memory s management:

Page 4 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

 Keeping track of which parts of memory are currently being used


and by whom.
 Deciding which processes (or parts thereof) and data to move into
and out of memory.
 Allocating and deallocating memory space as needed.

3. File Management
A file is a collected of related information defined by its creator.
Computer can store files on the disk (secondary storage), which
provide long term storage. Some examples of storage media are
magnetic tape, magnetic disk and optical disk. Each of these media
has its own properties like speed, capacity, and data transfer rate and
access methods. A file system normally organized into directories to
ease their use. These directories may contain files and other
directions.
The operating system responsible for the following activities in
connection with file management:
 The creation and deletion of files.
 The creation and deletion of directions.
 The support of primitives for manipulating files and directions.
 The mapping of files onto secondary storage.
 The backup of files on stable storage media.

4. I/O device Management


Input / Output device management provides an environment for the
better interaction between system and the I/O devices (such as
printers, scanners, tape drives etc.). To interact with I/O devices in an
effective manner, the operating system uses some special programs
known as device driver. The device drivers take the data that
operating system has defined as a file and then translate them into
streams of bits or a series of laser pulses (in regard with laser printer).
The I/O subsystem consists of several components:
 A memory management component that includes buffering,
caching, spooling
 A general device driver interface
 Drivers for specific hardware devices

Page 5 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

5. Secondary-Storage Management
The computer system provides secondary storage to back up main
memory. Secondary storage is required because main memory is too
small to accommodate all data and programs, and the data that it
holds is lost when power is lost. Most of the programs including
compilers, assemblers, word processors, editors, and formatters are
stored on a disk until loaded into memory. Secondary storage consists
of tapes drives, disk drives, and other media.
The operating system is responsible for the following activities in
connection with disk management:
 Free space management
 Storage allocation
 Disk scheduling.
c) Describe message passing system of interprocess communication 4M
(IPC)
Ans. Message Passing: In this model, communication takes place by Relevant
explanation
exchanging messages between cooperating processes. It allows
3M
processes to communicate and synchronize their action without
sharing the same address space. It is particularly useful in a Correct
distributed environment when communication process may reside on diagram 1M
a different computer connected by a network. Communication
requires sending and receiving messages through the kernel.
The processes that want to communicate with each other must have a
communication link between them. Between each pair of processes
exactly one communication link exists.

Page 6 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

d) What is CPU Scheduler? Explain the preemptive and non- 4M


preemptive type of scheduling
Ans. CPU Scheduler: When the CPU becomes idle, the CPU scheduler selects
one of the processes in the ready queue for execution. The CPU scheduler CPU
scheduler
selects a process from the processes in memory that are ready to execute
2M
and allocates the CPU to that process.
Relevant
Pre-emptive scheduling: - Once the CPU is allocated to a process, the CPU explanation
is forcefully removed from that process due to occurrence of interrupt or of
completion of I/O request by the requesting process. In this scheduling, a Preemptive
process changes its status from running state to ready state or waiting state 1M
to ready state. &
non-
Non-Preemptive scheduling: - Once the CPU is allocated to a process, the preemptive
1M
process keeps the CPU until it releases the CPU by terminating or by
switching to the waiting state. Control of CPU is with the process to which
it is [Link] this scheduling, a process changes its status from running
to waiting or running to terminate.

3. Attempt any THREE of the following: 12


a) Define Process. Draw a Process Control Block and explain the 4M
information in PCB
Ans. Process: A process is defined as, a program under execution, which
competes for the CPU time and other resources. Define
A process is a program in execution. Process is also called as job, task process
1M
and unit of work.
Diagram of
PCB with
correct
naming /
block
1M

Any 4
blocks of
information
in PCB
2M

Fig: Process Control Block

Page 7 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Following are the blocks in PCB:


1. Process Number: Each process is identified by its process
number, called Process Identification Number (PID). Every process
has a unique process-id through which it is identified. The process-id
is provided by the OS. The process id of two processes could not be
same because process-id is always unique.

2. Priority: Each process is assigned a certain level of priority that


corresponds to the relative importance of the event that it services
process priority is the preference of the one process over other
process for execution. Priority may be given by the user/system
manager or it may be given internally by OS. This field stores the
priority of a particular process.

3. Process State: This information is about the current state of the


process. The state may be new, ready, running, and waiting, halted,
and so on.

4. Program Counter: The counter indicates the address of the next


instruction to be executed for this process.

5. CPU Registers: The registers vary in number and type, depending


on the computer architecture. They include accumulators, index
registers, stack pointers, and general-purpose registers, plus any
condition-code information. Along with the program counter, this
state information must be saved when an interrupt occurs, to allow
the process to be continued correctly afterward.

6. CPU Scheduling Information: This information includes a


process priority, pointers to scheduling queues, and any other
scheduling parameters.

7. Memory Management Information: This information may


include such information as the value of the base and limit registers,
the page tables, or the segment tables, depending on the memory
system used by the operating system.

Page 8 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

8. Accounting Information: This information includes the amount of


CPU and real time used, time limits, account numbers, job or process
numbers, and so on.

9. I/O Status Information: This information includes the list of I/O


devices allocated to the process, a list of open files, and so on.

10. File Management: It includes information about all open files,


access rights etc.

11. Pointer: Pointer points to another process control block. Pointer


is used for maintaining the scheduling list.
b) Define deadlock. State the conditions necessary for deadlock. 4M
Ans. Deadlock: Deadlock is a situation when two or more processes get
locked and cannot processed further because of inter-dependability. Define
deadlock
In real world, deadlocks can arise when two persons wait for phone 1M
calls from one another.
OR State any 3
Deadlock is defined as, "a situation where a set of processes are conditions
blocked because each process is holding a resource and waiting for necessary
for deadlock
another resource acquired by some other process".
3M
Necessary Conditions to Deadlock:
Mutual Exclusion: At least one resource is held in a non-sharable
mode, that is only one process at a time can use the resource. If
another process requests that resource, the requesting process must be
delayed until the resource has been released. Each resource is either
currently assigned to exactly one process or is available.

Hold and Wait: There must exist a process that is holding at least
one resource and is waiting to acquire additional resources that are
currently being held by another process. Process currently holding
resources granted earlier can request new resources.

No Pre-emption: Resources cannot be pre-empted; i.e. resource can


only be released voluntarily by the process holding it, after the
process has completed its task. Resources previously granted cannot
be forcibly taken away from a process. They must be explicitly
released by the process holding them.

Page 9 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Circular Wait: There exist a set (P0, P1, ----- Pn) of waiting
processes such that P0 is waiting for a resource which is held by P1,
P1 is waiting for a resource which is held by P2. Pn-1 is waiting for
resources which are held by Pn and Pn is waiting for a resource which
is held by P0. Thus there must be a circular chain of two or more
processes, each of which is waiting for a resource held by the next
member of the chain.

c) Explain the following terms with respect to memory 4M


management:
i) Dynamic relocation Each term
ii) Swapping explanation
2M
Ans. i) Dynamic Relocation
When a program gets swapped out to a disk memory, then it is not
always possible that when it is swapped back into main memory then
it occupies the previous memory location, since the location may still
be occupied by another process. We may need to relocate the process
to a different area of memory. Thus there is a possibility that program
may be moved in main memory due to swapping.

ii) Swapping
Swapping is mechanism in which a process can be swapped
temporarily out of main memory (or move) to secondary storage
(disk) and make that memory available to other processes. At some
later time, the system swaps back the process from the secondary
storage to main memory.

Fig: swapping in memory management

Page 10 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

d) With suitable diagram, explain how contiguous file allocation is 4M


performed?
Ans. • The contiguous allocation method requires each file to occupy a Any
set of contiguous addresses on the disk. Disk addresses define a relevant
Diagram
linear ordering on the disk. Contiguous allocation of a file is 1M
defined by the disk address of the first block and its length. If the
file is ‘n’ blocks long and starts at location ‘b’, then it occupies Explanation
blocks b, b+1, b+2, - - - - - b+n-1. The directory entry for each 3M
file indicates the address of the starting block and the length of
the area allocated for this file.
• Contiguous allocation supports both sequential and direct access.
• For direct access to block ‘i’ of a file, which starts at block ‘b’,
we can immediately access block b+i. The difficulty with
contiguous allocation is finding space for a new file.
• For direct access to block ‘i’ of a file, which starts at block ‘b’,
we can immediately access block b+i.
• The difficulty with contiguous allocation is finding space for a
new file.
• If file to be created are ‘n’ blocks long, we must search free space
list for ‘n’ free contiguous blocks.

4. Attempt any THREE of the following: 12


a) Compare between Time sharing operating system and 4M
multiprogramming operative system.

Page 11 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Ans. Time sharing operating Multiprogramming Any 4


system operating system correct
points 1M
In this time sharing Operating Multiprogramming operating each
system many users/processes system allows to execute
are allocated with computer multiple processes by
resources in respective time monitoring their process states
slots. and switching in between
processes.
Processors time is shared with Processor and memory
multiple users that’s why it is underutilization problem is
called as time sharing operating resolved and multiple
system. programs runs on CPU that’s
why it is called
multiprogramming.
In this process, two or more In this, the process can be
users can use a processor in executed by a single
their terminal. processor.
Time sharing OS has fixed time Multi-programming OS has no
slice. fixed time slice.
Time sharing system minimizes Multiprogramming system
response time. maximizes processor use.
Example: Windows NT. Example: Mac OS.

b) Explain any four types of system call. 4M


Ans. [Link] and Job Control Explanation
 A running program needs to be able to halt its execution either of any 4
system calls
normally (end) or abnormally (abort). If the program discovers an 1M each
error in its input and wants to terminate abnormally, it may also
want to define an error level.
 A process or job executing one program may want to load and
execute another program. This allows the control card interpreter
to execute program as directly by the control cards of the user job.
If we create a new job or process, we should able to control its
execution.
 We may also want to terminate a job or process that we created
(terminate process). If we find that it is incorrect or no longer
needed we need waiting time to finish execution (wait time).
Another set of system calls are helpful in debugging a program.

Page 12 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Example of Process related system call:


a. End, Abort.
b. Load, Execute.
c. Create process, Terminate process.
d. Ready process, Dispatch process.
e. Suspend process, Resume process.
f. Get process attributes, Set process attributes.
g. Wait for Time.
h. Wait event, Signal event.
i. Change priority of process.

2. File Management
 We can identify several common system calls dealing with files.
We first need to be able to create and delete files such a system
call requires the name of the file and perhaps some of its
attributes.
 Once, the file is created, we need to open it and use it. We may
also read, write and reposition. Finally we need to close the file,
indicating that we are no longer using it.
Example of file related system call:
a. Create file, Delete file
b. Open a file, Close a file.
c. Create directory.
d. Read, Write, Reposition.
e. Get file attributes, Set file attributes.
f. Create a link.
g. Change working directory.

3. Device Management
 Files can be thought of as abstract or virtual devices. Thus many
of the system calls for files are also needed for devices.
 If there are multiple users of the system however we must first
request the device to ensure that we have exclusive use of it. After
we are finished with the device, we must release it. These
functions are similar to the open/close system calls for files.
 Once, the device has been requested we can read, write and
reposition the device just as with files.

Page 13 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

System call related to device management:


a. Request device, Release device.
b. Read, Write, Reposition.
c. Get device attributes, set device attributes.

4. Information Maintenance
 Many system calls exist simply for the purpose of transferring
information between the user program and the operating system.
For example most systems have a system call to return the current
time and date.
 Other system calls may return information about the system such
as the number of current users, the version number of the
operating system, the amount of free memory or disk space and so
on.
 In addition the operating system keeps information about all of its
jobs and processes and there are system calls to access this
information. Generally, there are also calls to reset it. (get process
attributes and set process attributes).
Information Maintenance related system call:
a. Get Time or Date, Set Time or Date.
b. Get system Data, Set system Data.
c. Get process, File or Device attributes.
d. Set process, File or Device attributes.
5. Communication
 There are two models of inter-process communication, the
message-passing model and the shared memory model.
 Message-passing uses a common mailbox to pass messages
between processes
 Shared memory use certain system calls to create and gain access
to regions of memory owned by other processes
Communication related system calls:
a. Establish a connection.
b. Send, receive messages.
c. Terminate a connection

c) Describe how context switch is executed by operating system 4M


Ans. • When CPU switches to another process, the system must save the Diagram
state of the old process and load the saved state for the new 1M
process. This task is known as a context switch.

Page 14 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

• CPU switching from one process to another process is called a


context switch. Explanation
3M
• Context switch times are highly dependent on hardware support.
Its speed varies from machine to machine, depending on the
memory speed, the number of registers that must be copied and
the existence of special instructions.
• This enables multiple processes to share a single CPU. The
context switch is an essential feature of a multitasking operating
system.
• When the process is switched, the following information is stored:
• Program Counter
• Scheduling Information
• Base and limit register value
• Currently used register
• Changed State
• I/O State
• Accounting

Fig: Context Switching


d) Compare Short Job First (SJF) and Shortest Remaining Time 4M
(SRTN) scheduling algorithm (any four points)
Ans. Any 4
Short Job First (SJF) Shortest Remaining Time correct
(SRTN) points 1M
It is a non-preemptive It is a preemptive algorithm. each
algorithm.
It involves less overhead than It involves more overheads
SRJF. than SJF.

Page 15 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

It leads to comparatively lower It leads to increased


throughput. throughput as execution time
is less.
It minimizes the average It may or may not minimize
waiting time for each process. the average waiting time for
each process.
It involves lesser number of It involves higher number of
context switching. context switching.
Short processes are executed Shorter processes run fast and
first and then followed by longer processes show poor
longer processes. response time.

e) Describe variable partitioning with the help of suitable example 4M


Ans. • In variable memory partitioning the partitions can vary in number
and size. In variable memory partitioning the amount of memory Explanation
allocated is exactly the amount of memory a process requires. 2M
• The operating system keeps a table indicating which parts of Any
memory are available and which are occupied. Initially all relevant
memory is available for user programs and is considered as one Example
large block of available memory, a hole. 2M
• When a job arrives and needs memory, we search for a hole large
enough for this job. If we find one, we allocate only as much as is
needed, keeping the rest available to satisfy future requests.

For example, assume 256K memory available and a resident monitor


of 40K. This situation leaves 216K for user programs.

Page 16 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

5. Attempt any TWO of the following: 12


a) Explain the use of following OS tools: 6M
i) Device Manager
ii) Task Scheduler
Ans. i) Device Manager use:
1. Managing all the hardware or virtual devices of computer system.
Any 2 uses
2. Allow interaction with hardware devices through device driver. of Device
3. Used to install device and component-level drivers as well as Manager
associated software. 1½ M each
4. Allocate devices to the process as per process requirement and
priority.
5. Deallocate devices either temporarily or permanently depending
on condition. Any 2 uses
6. Keeping track of all device’s data and location. of Task
7. Monitoring device status like printers, storage drivers and other Scheduler
devices. 1½ M each
8. Used to enforce the predetermined policies and decides which
process receives the device when and for how long.

ii) Task scheduler use:


1. Used to automate the execution of programs, scripts, and various
tasks at specific intervals or specific events.
2. Used to select the next jobs to be admitted into the system and the
next process to run.
3. Schedules tasks on CPU. Which task to run first, which has high
priority, which has low latency is decided by schedulers.

Page 17 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

4. Schedulers aim to provide fair access to system resources among


competing processes or users.
5. Task schedulers strive to maximize the overall throughput of the
system by executing tasks in a manner that minimizes idle time
and maximizes the number of tasks completed within a given
timeframe.
b) Explain user level thread and Kernel level thread with its 6M
advantages and disadvantages
Ans. User Level Thread For each
Thread
 In a user thread, all of the work of thread management is done by
explanation
the application and the kernel is not aware of the existence of 1M
threads.
 The thread library contains code for creating and destroying
threads, for passing message and data between threads, for 1 advantage
of each 1M
scheduling thread execution and for saving and restoring thread
contexts.
 The application begins with a single thread and begins running in
that thread. 1 Dis-
 User level threads are generally fast to create and manage. advantage
of each
1M
Advantages of user level thread over Kernel level thread:
1. Thread switching does not require Kernel mode privileges.
2. User level thread can run on any operating system. (Diagram
3. Scheduling can be application specific. optional)
4. User level threads are fast to create and manage.

Disadvantages of user level thread:


1. Limited Parallelism: Since user-level threads are managed within
the context of a single process, they are not well-suited for
applications that need to take full advantage of multi-core
processors or for applications that require parallel execution
across different processes.
2. Blocking: If a user-level thread blocks due to I/O or other reasons,
all threads in the same process can be blocked, leading to poor
utilization of resources.
3. No True Parallelism: User-level threads cannot execute in true
parallel on multi-core systems since they are managed by a single
kernel-level thread

Page 18 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

4. It is not appropriate for a multiprocessor system.

Kernel Level Threads


 In Kernel level thread, thread management done by the Kernel.
 There is no thread management code in the application area.
 Kernel threads are supported directly by the operating system.
 Any application can be programmed to be multithreaded.
 All of the threads within an application are supported within a
single process.
 The Kernel maintains context information for the process as a
whole and for individual threads within the process.
 Scheduling by the Kernel is done on a thread basis.
 The Kernel performs thread creation, scheduling and management
in Kernel space.
 Kernel threads are generally slower to create and manage than the
user threads.

Advantages of Kernel level thread:


1. Kernel can simultaneously schedule multiple threads from the
same process on multiple process.
2. If one thread in a process is blocked, the Kernel can schedule
another thread of the same process.
3. Kernel routines themselves can multithreaded.

Disadvantages:
1. Kernel threads are generally slower to create and manage than the
user threads.
2. Transfer of control from one thread to another within same process
requires a mode switch to the Kernel.

Page 19 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

c) Consider the string: 6M


0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7 with frame size 3 and 4,
calculate page fault in both the cases using FIFO algorithm
Ans. Note: Representation of frame can be in any order
FIFO : FIFO
implementat
i)Frame Size=3 ion with
frame size 3
3M

OR

Total Page Faults :16 FIFO


implementat
ii)Frame Size=4 ion with
frame size 4
3M

OR

Total Page Faults :08


6. Attempt any TWO of the following: 12
a) What is the average turnaround time for the following process 6M
using :
i) FCFS scheduling algorithm
ii) SJF non preemptive scheduling algorithm
iii) Round Robin Scheduling algorithm

Page 20 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Process Arrival time Burst time


P1 0 8
P2 1 4
P3 2 1
For each
Ans. Note :Any time slice can be considered by student for Round Robin algorithm:
e.g. 2, 3, 4 etc Gantt Chart
1M
i) Gantt Chart FCFS Correct
turnaround
P1 P2 P3 time
calculation
0 8 12 13 1M each

Turnaround Time =Completion Time - Arrival Time


P1=8-0=8
P2=12-1=11
P3=13-2=11
Average turnaround time=Turnaround time of all processes /
Number of processes
= (8+11+11) /3
=10 ms / Units

ii) Gantt Chart SJF non-preemptive

P1 P3 P2

0 8 9 13

Turnaround Time =Completion Time - Arrival Time


P1=8-0=8
P2=13-1=12
P3=9-2=7
Average turnaround time=Turnaround time of all processes /
Number of processes
= (8+12+7) /3
= 9 ms/ Units

Page 21 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

iii) Gantt Chart Round Robin

Consider Time Quantum= 2 Units

P1 P2 P3 P1 P2 P1 P1

0 2 4 5 7 9 11 13

Turnaround Time =Completion Time - Arrival Time


P1=13-0=13
P2=9-1=8
P3=5-2=3
Average turnaround time=Turnaround time of all processes /
Number of processes
= (13+8+3) /3
= 8 ms / Units
(OR)

Consider Time Quantum= 3 Units

P1 P2 P3 P1 P2 P1

0 3 6 7 10 11 13

Turnaround Time =Completion Time - Arrival Time


P1=13-0=13
P2=11-1=10
P3=7-2=5
Average turnaround time=Turnaround time of all processes /
Number of processes
= (13+10+5) /3
= 9.33 ms/ Units
b) Explain bit map vector and linked list free space management 6M
techniques with its advantages and disadvantages
Ans. 1 )Bitmap Vector: Bitmap
Vector
The free-space list is implemented as a bit map or bit vector.
explanation
1M
Each block is represented by 1 bit. If the block is free, the bit is 1; if
the block is allocated, the bit is 0.

Page 22 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

For example, consider a disk where blocks 2, 3, 4, 5, 8, 9, 10, 11, 12,


13 are free and the rest of the blocks are allocated. Any 1
Advantage
The free-space bit map would be : 0011110011111100 1M,

Any 1
Disadvantag
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 e 1M

0 0 1 1 1 1 0 0 1 1 1 1 1 1 0 0

1=Free block 0= Allocated block Linked List


explanation
The main advantage of this approach is its relative simplicity and its 1M
efficiency in finding the first free block or n consecutive free blocks
on the disk. Any 1
Advantage
Advantages of Bit Map vector method 1M
1. Simple and easy to understand.
2. Consumes less memory. Any 1
3. It is efficient to find free space. Disadvantag
Disadvantages of the Bit Map vector method e 1M
1. The operating system goes through all the blocks until it finds
a free block.
(diagram is
2. It is not efficient when the disk size is large.
optional)
2) Linked List
In this approach, the free disk blocks are linked together i.e. a free
block contains a pointer to the next free block. The block number of
the very first disk block is stored at a separate location on disk and is
also cache in memory. In this approach, link all the disk blocks
together, keeping a pointer to the first free block. This block contains
a pointer to the next free disk block, and so on.

Page 23 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Advantages of linked list:


1. Files can be extended, no fragmentation problems.
2. Sequential Access is easy: just chase links.
3. No extra space for the free list.
4. Starting and ending of the file can be easily found out by the
linked list.
Disadvantages of linked list:
1. Cannot be effectively used for direct access method.
2. Random access is virtually impossible. Lots of seeking, even
in sequential access.
3. Pointers which are required need additional memory space.
4. It is not reliable as the blocks are scattered on the disk
anywhere.
c) Explain with diagram single level directory structure and two 6M
level directory structure with its advantages and disadvantages.
Ans. Single Level Directory Structure: Single level
This is the simplest directory structure. All the files are stored in the directory
same directory which is easy to support and understand. But a unique structure
name must be assigned to each file. explanation
If the number of files in the directory increases, it may become 1M,
difficult to remember names of all files.
Advantage:
 Less time required to search the file, because all files are Any 1
stored in same directory. Advantage
 Single level directory structure is easy to implement and 1M
maintain.
 Single level directory structure, the operations like creation,
searching, deletion, updating are very easy and faster

Page 24 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Disadvantages
 Not suitable for a large number of files and more than one
Any 1
user. disadvantag
 Because of single directory files, files require unique file e 1M
names.
 Difficult to remember names of all the files as the number of Two level
files increases. MS-DOS OS allows only 11 character file directory
structure
name where as UNIX allows 255 character. explanation
1M

Any 1
Advantage
1M

Any 1
disadvantag
e 1M

Two-level directory structure: -In the two-level structures, each


user has its own user file directory (UFD). The UFD lists only files of
a single user. System contains a master file directory (MFD) which is
indexed by user name or account number. Each entry in MFD points
to the UFD for that user.

When a user refers to a particular file, only his own UFD is searched.
Different users can have files with the same name, as long as all the
file names within each UFD are unique.

When we create a file for a user, operating system searches only that
user’s UFD to find whether same name file already present in the
directory. For deleting a file again operating system checks the file
name in the user’ UFD only.

Page 25 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

SUMMER – 2024 EXAMINATION


MODEL ANSWER
Subject: Operating System Subject Code: 22516

Advantages:
 It solves isolation. i.e. data of one user is separated from other
user.
 Searching is also efficient in this type of structure.
 Every user accesses his own directory and files.
 There is no problem of files with same names in different
directories.
Disadvantages:
 Two users can not share data or communicate with each other.
 It is difficult to search the files with same names in different
directories.

Page 26 / 26

Downloaded From Campusify!


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

WINTER – 19 EXAMINATIONS
Subject Name: Client Side Scripting Model Answer Subject Code: 22519
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in
the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner
may try to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components
indicated in the figure. The figures drawn by candidate and model answer may vary.
The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constant values may vary and there may be some difference in the candidate’s
answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of
relevant answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based
on equivalent concept.

Q. Sub Answer Marking


No. Q. Scheme
N.
1 Attempt any FIVE of the following : 10 M
a List any four features of Java script. 2M
Ans Features of Java script Any four
features : ½
1. JavaScript is a object-based scripting language. M each
2. Giving the user more control over the browser.
3. It Handling dates and time.
4. It Detecting the user's browser and OS,
5. It is light weighted.
6. Client – Side Technology
7. JavaScript is a scripting language and it is not java.
8. JavaScript is interpreter based scripting language.
9. JavaScript is case sensitive.
10. JavaScript is object based language as it provides predefined objects.
11. Every statement in javascript must be terminated with semicolon (;).
12. Most of the javascript control statements syntax is same as syntax of
control statements in C language.
13. An important part of JavaScript is the ability to create new functions
within scripts. Declare a function in JavaScript
using function keyword.
b List the comparison operators in Java script. 2M

Page 1 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Comparison operators in Java script Any 4


operators
== Equal to :1/2 M each
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
=== Equal value and equal
type
!== not equal value or not
equal type
c Write a Java script to create person object with properties firstname, 2M
lastname, age, eyecolor, delete eyecolor property and display remaining
properties of person object.
Ans <html> Create
person
<body> object : 1M
<script>

var person = {
firstname:"John",
lastname:"Doe",
age:50,
eyecolor:"blue"
}; Delete and
display
delete [Link]; //delete person eyecolor
properties :
[Link]("After delete "+ [Link] +" "+ [Link] +" " 1M
+[Link] +" "+ [Link]);
</script>

</body>
</html>
d Write a Java script that initializes an array called flowers with the names of 2M
3 flowers. The script then displays array elements.
Ans <html> Initialization
of array :
<head> 1M,

Page 2 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

<title>Display Array Elements</title>


</head> Display of
array
<body> elements :
1M
<script>
var flowers = new Array();
flowers[0] = 'Rose ';

flowers[1] = 'Mogra';
flowers[2] = 'Hibiscus';
for (var i = 0; i < [Link]; i++)
{
[Link](flowers[i] + '<br>');
}
</script>

</body>
</html>
e Write Javascript to call function from HTML. 2M
Ans <html> Function
declaration :
<head> 1M,
<title>Calling function from HTML</title>
<script> Function
call from
function welcome()
HTML: 1M
{
alert("Welcome students");
(Any other
} example
allowed)
function goodbye()
{

alert("Bye");

Page 3 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

}
</script>
</head>
<body onload="welcome()" onunload="goodbye()">
</body>
</html>
f Write a Javascript to design a form to accept values for user ID & password. 2M
Ans <html> Correct
syntax: 1M,
<body>
<form name="login">
Correct
Enter Username<input type="text" name="userid"><br> logic: 1M
Enter Password<input type="password" name="pswrd">
<input type="button" onclick="display()" value="Display">
</form>

<script language="javascript">
function display()
{
[Link]("User ID "+ [Link] + "Password :
"+[Link]);
}
</script>
</body>
</html>
g State any two properties and methods of location object. 2M
Ans Properties of location object: Any 2
properties :
1. hash ½ M each
2. host
3. hostname
4. href
5. origin

Page 4 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

6. pathname
7. port
8. protocol
9. search
Any 2
Methods of location object: methods : ½
M each
1. assign( )
2. reload( )
3. replace( )

2 Attempt any THREE of the following : 12 M


a Explain getter and setter properties in Java script with suitable example. 4M
Ans Property getters and setters Explanation
1. The accessor properties. They are essentially functions that work on : 2M
getting and setting a value.
2. Accessor properties are represented by “getter” and “setter” methods. In
an object literal they are denoted by get and set.
let obj = {
get propName() {
// getter, the code executed on getting [Link]
},

set propName(value) {
// setter, the code executed on setting [Link] = value
}
};

3. An object property is a name, a value and a set of attributes. The value


may be replaced by one or two methods, known as setter and a getter.
4. When program queries the value of an accessor property, Javascript
invoke getter method(passing no arguments). The retuen value of this
method become the value of the property access expression.
5. When program sets the value of an accessor property. Javascript invoke
the setter method, passing the value of right-hand side of assignment. This
method is responsible for setting the property value.
 If property has both getter and a setter method, it is read/write
property.
 If property has only a getter method , it is read-only property.
 If property has only a setter method , it is a write-only property.
6. getter works when [Link] is read, the setter – when it is assigned.

Example:
<html>

Page 5 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

<head>
<title>Functions</title>
<body> Example :
<script language="Javascript"> 2M
var myCar = {
/* Data properties */
defColor: "blue",
defMake: "Toyota",
(Any other
/* Accessor properties (getters) */ example can
get color() { be
return [Link]; considered)
},
get make() {
return [Link];
},

/* Accessor properties (setters) */


set color(newColor) {
[Link] = newColor;
},
set make(newMake) {
[Link] = newMake;
}
};
[Link]("Car color:" + [Link] + " Car Make: "+[Link])
/* Calling the setter accessor properties */
[Link] = "red";
[Link] = "Audi";
/* Checking the new values with the getter accessor properties */
[Link]("<p>Car color:" + [Link]); // red
[Link](" Car Make: "+[Link]); //Audi
</script>
</head>
</body>
</html>
b Explain prompt() and confirm() method of Java script with syntax and 4M
example.
Ans prompt() For Each
explanation/
The prompt () method displays a dialog box that prompts the visitor for [Link]
prompt () method returns the input value if the user clicks "OK". If the user clicks syntax : 1M,
"cancel" the method returns null.
Example :
Syntax: [Link] (text, defaultText) 1M

Page 6 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Example: (Any other


<html> example can
<script type="text/javascript"> be
considered)
function msg(){
var v= prompt("Who are you?");
alert("I am "+v);
}
</script>

<input type="button" value="click" onclick="msg()"/>


</html>
confirm()
It displays the confirm dialog box. It has message with ok and cancel buttons.
Returns Boolean indicating which button was pressed
Syntax:
[Link]("sometext");
Example :
<html>
<script type="text/javascript">
function msg(){
var v= confirm("Are u sure?");
if(v==true){
alert("ok");
}

else{
alert("cancel");
}
}
</script>
<input type="button" value="delete record" onclick="msg()"/>

</html>

Page 7 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

c Write a Java script program which computes, the average marks of the 4M
following students then, this average is used to determine the corresponding
grade.
Student Name Marks
Sumit 80
Kalpesh 77
Amit 88
Tejas 93
Abhishek 65

The grades are computed as follows :


Range Grade
<60 E
<70 D
<80 C
<90 B
<100 A
Ans <html> Correct
logic : 2M,
<head>
Correct
<title>Compute the average marks and grade</title> Syntax: 2M
</head> (any other
logic can be
<body>
considered)
<script>
var students = [['Summit', 80], ['Kalpesh', 77], ['Amit', 88], ['Tejas', 93],
['Abhishek', 65]];
var Avgmarks = 0;
for (var i=0; i < [Link]; i++) {
Avgmarks += students[i][1];
}
var avg = (Avgmarks/[Link]);

[Link]("Average grade: " + (Avgmarks)/[Link]);


[Link]("<br>");
if (avg < 60){

Page 8 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

[Link]("Grade : E");
}
else if (avg < 70) {
[Link]("Grade : D");
}
else if (avg < 80) {

[Link]("Grade : C");
} else if (avg < 90) {
[Link]("Grade : B");
} else if (avg < 100) {
[Link]("Grade : A");
}
</script>

</body>
</html>

Output (Optional)
Average grade: 80.6
Grade : B
d Write the use of chatAt() and indexof() with syntax and example. 4M
Ans charAt() Each syntax
: 1M,
The charAt() method requires one argument i.e is the index of the character that
you want to copy.

Syntax: Example :
1M
var SingleCharacter = [Link](index);

Example:

var FirstName = 'Bob';

Page 9 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

var Character = [Link](0); //o/p B

indexOf()
The indexOf() method returns the index of the character passed to it as an
argument.
If the character is not in the string, this method returns –1.

Syntax:
var indexValue = [Link]('character');

Example:
var FirstName = 'Bob';

var IndexValue = [Link]('o'); //o/p index as 1

3 Attempt any THREE of the following : 12 M


a Differentiate between concat() and join() methods of array object. 4M
Ans concat() join()

Array elements can be combined by Array elements can be combined by


using concat() method of Array using join() method of Array object.
object.

The concat() method separates each The join() method also uses a comma
value with a comma. to separate values, but you can
specify a character other than a
comma to separate values.

Eg: Eg:
var str = [Link]() var str = [Link](' ')
The value of str in this case is
The value of str is 'BMW Audi Maruti'
'BMW, Audi, Maruti'

b Write a JavaScript that will replace following specified value with another 4M
value in string.

Page 10 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

String = “I will fail”


Replace “fail” by “pass”
Ans <html> Correct
program
<head> with any
proper logic:
<body>
4M
<script>
var myStr = ‘I will fail’;
var newStr = [Link](fail, "pass");
[Link](newStr);
</script>

</body>
</head>
</html>

c Write a Java Script code to display 5 elements of array in sorted order. 4M


Ans <html> Correct
program
<head> with any
proper logic
<title> Array</title>
:4M
</head>
<body>

<script>
var arr1 = [ “Red”, “red”, “Blue”, “Green”]
[Link](“Before sorting arra1=” + arr1);
[Link](“<br>After sorting arra1=” + [Link]());
</script>
</body>

</html>

d Explain open() method of window object with syntax and example. 4M

Page 11 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans The open() method of window object is used to open a new window and loads the Explanation:
document specified by a given URL. 1M
MyWindow = [Link]() syntax: 1 M
The open() method returns a reference to the new window, which is assigned to
Example: 2
the MyWindow variable. You then use this reference any time that you want to
do something with the window while your JavaScript runs. M
A window has many properties, such as its width, height, content, and name—to
mention a few. You set these attributes when you create the window by passing
(Any other
them as parameters to the open() method:
example can
be
• The first parameter is the full or relative URL of the web page that will appear
considered)
in the new window.
• The second parameter is the name that you assign to the window.
• The third parameter is a string that contains the style of the window.
We want to open a new window that has a height and a width of 250 pixels and
displays an advertisement that is an image. All other styles are turned off.

Syntax:

MyWindow = [Link](‘[Link]’, 'myAdWin', 'status=0, toolbar=0,


location=0, menubar=0, directories=0, resizable=0, height=250, width=250')

Example:

<html >
<head>
<title>Open New Window</title>
<script >
function OpenNewWindow() {
MyWindow = [Link](‘[Link]’, 'myAdWin', 'status=0, toolbar=0,
location=0,
menubar=0, directories=0, resizable=0, height=250, width=250')
}
</script>
</head>
<body>
<FORM action=" " method="post">
<INPUT name="OpenWindow" value="Open Window" type="button"
onclick="OpenNewWindow()"/>
</FORM>
</body>
</html>

Page 12 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

4 Attempt any THREE of the following : 12 M


a Describe regular expression. Explain search () method used in regular 4M
expression with suitable example.
Ans Regular Expression: Regular
A regular expression is very similar to a mathematical expression, except a Expression:
regular expression tells the browser how to manipulate text rather than numbers 1M
by using special symbols as operators.
search()
Search() method: method: 1 M
[Link]() method takes a regular expression/pattern as argument and search
for the specified regular expression in the string. This method returns the index Example:
where the match found. 2M

Example:

<html>
<body>
<script>
function myFunction() {

// input string
var str = "Good Morning!";

// searching string with modifier i


var n = [Link](/Morning/i);

[Link](n + '<br>');

// searching string without modifier i


var n = [Link](/Morning/);

[Link](n);
}
myFunction();
</script>
</body>
</html>
b List ways of protecting your web page and describe any one of them. 4M
Ans Ways of protecting Web Page: List: 1 M

1)Hiding your source code Explanation


2)Disabling the right MouseButton any one: 3M
3) Hiding JavaScript
4) Concealing E-mail address.

Page 13 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

1) Hiding your source code

The source code for your web page—including your JavaScript—is stored in the
cache, the part of computer memory where the browser stores web pages that
were requested by the visitor. A sophisticated visitor can access the cache and
thereby gain access to the web page source code.
However, you can place obstacles in the way of a potential peeker. First, you can
disable use of the right mouse button on your site so the visitor can't access the
View Source menu option on the context menu. This hides both your HTML code
and your JavaScript from the visitor.
Nevertheless, the visitor can still use the View menu's Source option to display
your source code. In addition, you can store your JavaScript on your web server
instead of building it into your web page. The browser calls the JavaScript from
the web server when it is needed by your web page.
Using this method, the JavaScript isn't visible to the visitor, even if the visitor
views the source code for the web page.

2)Disabling the right MouseButton

The following example shows you how to disable the visitor's right mouse button
while the browser displays your web page. All the action occurs in the JavaScript
that is defined in the <head> tag of the web page.

The JavaScript begins by defining the BreakInDetected() function. This function


is called any time the visitor clicks the right mouse button while the web page is
displayed. It displays a security violation message in a dialog box whenever a
visitor clicks the right mouse button
The BreakInDetected() function is called if the visitor clicks any button other
than the left mouse button.

Example:

<html>
<head>
<title>Lockout Right Mouse Button</title>
<script language=JavaScript>

function BreakInDetected(){
alert('Security Violation')
return false
}
function NetscapeBrowser(e){
if ([Link]||
[Link]&&![Link]){
if ([Link]==2||[Link]==3){

Page 14 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

BreakInDetected()
return false
}
}
}
function InternetExploreBrowser(){
if ([Link]==2){
BreakInDetected()
return false
}
}
if ([Link]){
[Link]([Link])
[Link]=NetscapeBrowser()
}
else if ([Link]&&![Link]){
[Link]=InternetExploreBrowser()
}
[Link]=new Function(
"BreakInDetected();return false")

</script>
</head>
<body>
<table width="100%" border=0>
<tbody>
<tr vAlign=top>
<td width=50>
<a>
<ing height=92 src="[Link]"
width=70 border=0
onmouseover="src='[Link]'"
onmouseout="src='[Link]'">
</a>
</td>
<td>
<img height=1 src="" width=10>
</td>
<td>
<a>
<cTypeface:Bold><u> Rose Flower</U></b>
</a>
</font><font face="arial, helvetica, sans-serif"
size=-1><BR>Rose Flower

Page 15 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

</td>
</tr>
</tbody>
</table>
</body>
</html>

3) Hiding JavaScript

You can hide your JavaScript from a visitor by storing it in an external fi le on


your web server. The external fi le should have the .js fi le extension. The browser
then calls the external file whenever the browser encounters a JavaScript element
in the web page. If you look at the source code for the web page, you'll see
reference to the external .js fi le, but you won't see the source code for the
JavaScript.
The next example shows how to create and use an external JavaScript file. First
you must tell the browser that the content of the JavaScript is located in an
external
file on the web server rather than built into the web page. You do this by assigning
the fi le name that contains the JavaScripts to the src attribute of the <script>
tag, as shown here:

<script src="[Link]"
language="Javascript" type="text/javascript">

Next, you need to defi ne empty functions for each function that you define in the
external JavaScript fi le.

<html >
<head>
<title>Using External JavaScript File</title>
<script src="[Link]" language="Javascript" type="text/javascript">

function OpenNewWindow(book) {
}
</script>
</head>
<body>
<tablewidth="100%" border=0>
<tbody>
<tr vAlign=top>
<td width=50>
<a>
<img height=92 src="[Link]" width=70 border=0 name='cover'>
</a>

Page 16 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

</td>
<td>
<img height=1 src="" width=10>
</td>
<td>
<a onmouseover="OpenNewWindow(1)" onmouseout="[Link]()">
<b><u>Rose </u></b>
</a>
<br>
<a onmouseover="OpenNewWindow(2)" onmouseout="[Link]()">
<b><u>Sunflower</U></b>
</a>
<br>
<A onmouseover="OpenNewWindow(3)" onmouseout="[Link]()">
<b><u>Jasmine </u></b>
</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>

The final step is to create the external JavaScript fi le. You do this by placing all
function definitions into a new fi le and then saving the fi le using the .js
extension.
[Link] file:

function OpenNewWindow(book) {
if (book== 1)
{
[Link]='[Link]'
MyWindow = [Link]('', 'myAdWin', 'titlebar=0 status=0, toolbar=0,
location=0, menubar=0, directories=0, resizable=0, height=50,
width=150,left=500,top=400')
[Link]( 'Rose flower')
}
if (book== 2)
{
[Link]='[Link]'
MyWindow = [Link]('', 'myAdWin', 'titlebar=0 status=0, toolbar=0,
location=0, menubar=0, directories=0, resizable=0, height=50,
width=150,left=500,top=500')
[Link]( 'sunflower flower')
}

Page 17 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

if (book== 3)
{
[Link]='[Link]'
MyWindow = [Link]('', 'myAdWin', 'titlebar=0
status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=0,
height=50,
width=150,left=500,top=600')
[Link]( 'Jasmine Flower')
}
}

After you create the external JavaScript fi le, defi ne empty functions for each
function that is contained in the external JavaScript fi le, and reference the
external
JavaScript fi le in the src attribute of the <script> tag, you're all set.

4) Concealing E-mail address:

Many of us have endured spam at some point and have probably blamed every
merchant we ever patronized for selling our e-mail address to spammers. While
e-mail addresses are commodities, it's likely that we ourselves are the culprits
who invited spammers to steal our e-mail addresses.
Here's what happens: Some spammers create programs called bots that surf the
Net looking for e-mail addresses that are embedded into web pages, such as those
placed there by developers to enable visitors to contact them. The bots then strip
these e-mail addresses from the web page and store them for use in a spam attack.
This technique places developers between a rock and a hard place. If they place
their e-mail addresses on the web page, they might get slammed by spammers. If
they don't display their e-mail addresses, visitors will not be able to get in touch
with the developers.
The solution to this common problem is to conceal your e-mail address in the
source code of your web page so that bots can't fi nd it but so that it still appears
on the web page. Typically, bots identify e-mail addresses in two ways: by the
mailto: attribute that tells the browser the e-mail address to use when the visitor
wants to respond to the web page, and by the @ sign that is required of all e-mail
addresses. Your job is to confuse the bots by using a JavaScript to generate the
e-mail address dynamically. However, you'll still need to conceal the e-mail
address in your JavaScript, unless the JavaScript is contained in an external
JavaScript file, because a bot can easily recognize the mailto: attribute and the @
sign in a JavaScript.
Bots can also easily recognize when an external fi le is referenced. To conceal an
e-mail address, you need to create strings that contain part of the e-mail address
and then build a JavaScript that assembles those strings into the e-mail address,
which is then written to the web page.
The following example illustrates one of many ways to conceal an e-mail address.

Page 18 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

It also shows you how to write the subject line of the e-mail. We begin by
creating four strings:

• The first string contains the addressee and the domain along with symbols &, *,
and _ (underscore) to confuse the bot.
• The second and third strings contain portions of the mailto: attribute name.
Remember that the bot is likely looking for [Link]
• The fourth string contains the subject line. As you'll recall from your HTML
training, you can generate the TO, CC, BCC, subject, and body of an e-mail from
within a web page.
You then use these four strings to build the e-mail address. This process starts by
using the replace() method of the string object to replace the & with the @ sign
and the * with a period (.). The underscores are replaced with nothing, which is
the
same as simply removing the underscores from the string.
All the strings are then concatenated and assigned to the variable b, which is then
assigned the location attribute of the window object. This calls the e-mail program
on the visitor's computer and populates the TO and Subject lines with the strings
generated by the JavaScript.

<html>
<head>
<title>Conceal Email Address</title>
<script>
function CreateEmailAddress(){
var x = manish*c_o_m'
var y = 'mai'
var z = 'lto'
var s = '?subject=Customer Inquiry'
x = [Link]('&','@')
x = [Link]('*','.')
x = [Link]('_','')
x = [Link]('_','')
var b = y + z +':'+ x + s
[Link]=b
}
-->
</script>
</head>
<body>
<input type="button" value="Help"
onclick="CreateEmailAddress()">
</body>
</html>

Page 19 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

c Create a slideshow with the group of three images, also simulate next and 4M
previous transition between slides in your Java Script.
Ans <html> Correct
<head> program: 4
<script> M
pics = new Array('[Link]' , '[Link]' , '[Link]');
count = 0; (Any other
function slideshow(status) example can
{ be
if ([Link]) considered)
{
count = count + status;
if (count > ([Link] - 1))
{
count = 0;
}
if (count < 0)
{
count = [Link] - 1;
}
[Link] = pics[count];
}
}
</script>
</head>
<body>
<img src="[Link]" width="200" name="img1">
<br>
<input type="button" value="Next" onclick="slideshow(1)">
<input type="button" value="Back" onclick="slideshow(-1)">
</body>
</html>
d Explain text rollover with suitable example. 4M
Ans You create a rollover for text by using the onmouseover attribute of the <A> tag, Explanation:
which is the anchor tag. You assign the action to the onmouseover attribute the 2M
same way as you do with an <IMG> tag. Program: 2
Let's start a rollover project that displays a flower titles. Additional information M
about a flower can be displayed when the user rolls the mouse cursor over the
flower name. In this example, the image of the flower is displayed. However, (Any other
you could replace the flower image with an advertisement or another message example can
that you want to show about the flower. be
considered)
<html>
<head>
<title>Rollover Text</title>

Page 20 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

</head>
<body>
<TABLE width="100%" border="0">
<TBODY>
<TR vAlign="top">
<TD width="50">
<a>
<IMG height="92" src="[Link]"
width="70" border="0" name="cover">
</a>
</TD>
<TD>
<IMG height="1" src="" width="10">
</TD>
<TD>
<A onmouseover= "[Link]='[Link]'">
<B><U>Sunflower</U></B>
</A>
<BR>
<A onmouseover=
"[Link]='[Link]'">
<B><U>Jasmine</U></B>
</A>
<BR>
<A onmouseover=
"[Link]='[Link]'">
<B><U>Rose</U></B>
</A>
</TD>
</TR>
</TBODY>
</TABLE>
</body>
</html>
e Write a Java script to modify the status bar using on MouseOver and on 4M
MouseOut with links. When the user moves his mouse over the links, it will
display “MSBTE” in the status bar. When the user moves his mouse away
from the link the status bar will display nothing.
Ans <html> Correct
<head> program: 4
<title>JavaScript Status Bar</title></head> M
<body>
<a href=" [Link]
onMouseOver="[Link]='MSBTE';return true"
onMouseOut="[Link]='';return true">

Page 21 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

MSBTE

</a>
</body>
</html>

5 Attempt any TWO of the following : 12 M


a Write a HTML script which displays 2 radio buttons to the users for fruits 6M
and vegetables and 1 option list. When user select fruits radio button option
list should present only fruits names to the user & when user select vegetable
radio button option list should present only vegetable names to the user.
Ans <html> Correct
<head> script code:
<title>HTML Form</title> 4M
<script language="javascript" type="text/javascript"> HTML
function updateList(ElementValue) code: 2M
{
with([Link])
{
if(ElementValue == 1)
{
optionList[0].text="Mango";
optionList[0].value=1;
optionList[1].text="Banana";
optionList[1].value=2;
optionList[2].text="Apple";
optionList[2].value=3;
}
if(ElementValue == 2)
{
optionList[0].text="Potato";
optionList[0].value=1;
optionList[1].text="Cabbage";
optionList[1].value=2;
optionList[2].text="Onion";
optionList[2].value=3;
}
}
}
</script>
</head>
<body>
<form name="myform" action="" method="post">
<p>

Page 22 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

<select name="optionList" size="2">


<option value=1>Mango
<option value=2>Banana
<option value=3>Apple
</select>
<br>
<input type="radio" name="grp1" value=1 checked="true"
onclick="updateList([Link])">Fruits
<input type="radio" name="grp1" value=2
onclick="updateList([Link])">Vegetables
<br>
<input name="Reset" value="Reset" type="reset">
</p>
</form>
</body>
</html>
b Describe, how to read cookie value and write a cookie value. Explain with 6M
example.
Ans Web Browsers and Servers use HTTP protocol to communicate and HTTP is a Reading
stateless protocol. But for a commercial website, it is required to maintain cookie with
session information among different pages. For example, one user registration example:
ends after completing many pages. But how to maintain users' session 3M
information across all the web pages. Writing
cookie with
Cookies are a plain text data record of 5 variable-length fields − example:
 Expires − The date the cookie will expire. If this is blank, the cookie will 3M
expire when the visitor quits the browser. **Note:
Combined of
 Domain − The domain name of your site. both code is
 Path − The path to the directory or web page that set the cookie. This also
may be blank if you want to retrieve the cookie from any directory or acceptable
page.
 Secure − If this field contains the word "secure", then the cookie may
only be retrieved with a secure server. If this field is blank, no such
restriction exists.
 Name=Value − Cookies are set and retrieved in the form of key-value
pairs
Cookies were originally designed for CGI programming. The data contained in
a cookie is automatically transmitted between the web browser and the web
server, so CGI scripts on the server can read and write cookie values that are
stored on the client.

Page 23 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

JavaScript can also manipulate cookies using the cookie property of


the Document object. JavaScript can read, create, modify, and delete the cookies
that apply to the current web page.

Storing Cookies
The simplest way to create a cookie is to assign a string value to the
[Link] object, which looks like this.
[Link] = "key1 = value1;key2 = value2;expires = date";
Here the expires attribute is optional. If you provide this attribute with a valid
date or time, then the cookie will expire on a given date or time and thereafter,
the cookies' value will not be accessible.
<html>
<head>
<script type = "text/javascript">
<!--
function WriteCookie()
{
if( [Link] == "" ) {
alert("Enter some value!");
return;
}
cookievalue = escape([Link]) + ";";
[Link]="name=" + cookievalue;
[Link] ("Setting Cookies : " + "name=" + cookievalue );
}
//-->
</script>
</head>
<body>
<form name = "myform" action = "">
Enter name: <input type = "text" name = "customer"/>
<input type = "button" value = "Set Cookie" onclick = "WriteCookie();"/>
</form>
</body>
</html>

Reading Cookies
Reading a cookie is just as simple as writing one, because the value of the
[Link] object is the cookie. So you can use this string whenever you
want to access the cookie. The [Link] string will keep a list of
name=value pairs separated by semicolons, where name is the name of a cookie
and value is its string value.

Page 24 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

You can use strings' split() function to break a string into key and values as
follows:-
<html>
<head>
<script type = "text/javascript">
<!--
function ReadCookie()
{
var allcookies = [Link];
[Link] ("All Cookies : " + allcookies )
// Get all the cookies pairs in an array
cookiearray = [Link](';');

// Now take key value pair out of this array


for(var i=0; i<[Link]; i++) {
name = cookiearray[i].split('=')[0];
value = cookiearray[i].split('=')[1];
[Link] ("Key is : " + name + " and Value is : " + value);
}
}
//-->
</script>

</head>
<body>

<form name = "myform" action = "">


<p> click the following button and see the result:</p>
<input type = "button" value = "Get Cookie" onclick =
"ReadCookie()"/>
</form>

Page 25 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

</body>
</html>
c Write a java script that displays textboxes for accepting name & email ID & 6M
a submit button. Write java script code such that when the user clicks on
submit button
(1) Name Validation
(2) Email ID Validation.
Ans <html> Correct
<head> Html code:
<title>Form Validation</title> 2M
</head>
<body> Correct
<form action = "/cgi-bin/[Link]" name = "myForm" onsubmit = Script code:
"return(validate());"> 4M
<table cellspacing = "2" cellpadding = "2" border = "1">
(Any other
<tr>
example can
<td align = "right">Name</td>
be
<td><input type = "text" name = "Name" /></td>
considered)
</tr>

<tr>
<td align = "right">EMail</td>
<td><input type = "text" name = "EMail" /></td>
</tr>

<tr>
<td align = "right"></td>
<td><input type = "submit" value = "Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
<script type = "text/javascript">
<!--
// Form validation code will come here.
function validate() {
if( [Link] == "" ) {
alert( "Please provide your name!" );
[Link]() ;
return false;
}
if( [Link] == "" ) {

Page 26 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

alert( "Please provide your Email!" );


[Link]() ;
return false;
}
var emailID = [Link];
atpos = [Link]("@");
dotpos = [Link](".");

if (atpos < 1 || ( dotpos - atpos < 2 )) {


alert("Please enter correct email ID")
[Link]() ;
return false;
}
return( true );
}
//-->
</script>

6 Attempt any TWO of the following : 12 M


a Describe how to evaluate checkbox selection. Explain with suitable example. 6M
Ans Evaluating Checkbox Selection: Correct
Explanation
 A checkbox is created by using the input element with the : 3M
type=”checkbox” attribute-value pair.
 A checkbox in a form has only two states(checked or un-checked) and is &
independent of the state of other checkboxes in the form. Check boxes can
be grouped together under a common name. Correct
Example:3M
 You can write javascript function that evaluates whether or not a check
box was selected and then processes the result according to the needs of
(Any other
your application.
example can
 Following example make use of five checkboxes to provide five options
be
to the user regarding fruit.
considered)
<html>
<head>
<title>HTML Form</title>
<script language="javascript" type="text/javascript">
function selection()
{
var x ="You selected: ";
with([Link])
{
if([Link] == true)
{
x+= [Link]+ " ";

Page 27 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

}
if([Link] == true)
{
x+= [Link]+ " ";
}
if([Link] == true)
{
x+= [Link]+ " ";
}
if([Link] == true)
{
x+= [Link]+ " ";
}
if([Link] == true)
{
x+= [Link]+ " ";
}
[Link](x);
}
}
</script>
</head>
<body>
<form name="myform" action="" method="post">
Select Your Favourite Fruits: <br>
<input type="checkbox" name="a" value="Apple">Apple
<input type="checkbox" name="b" value="Banana">Banana
<input type="checkbox" name="o" value="Orange">Orange
<input type="checkbox" name="p" value="Pear">Pear
<input type="checkbox" name="g" value="Grapes">Grapes
<input type="reset" value="Show" onclick="selection()">
</form>
</body>
</html>

</form>
</body>
</html>

Page 28 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

b Write a script for creating following frame structure 6M

FRUITS, FLOWERS AND CITIES are links to the webpage [Link],


[Link], [Link] respectively. When these links are clicked
corresponding data appears in FRAME 3.
Ans <html> Frame part:
<head> 2M for each
<title>Frame Demo</title>
</head>
<body>
<table border="1">
<tr>
<td align="center" colspan="2">
FRAME 1
</td>
</tr>
<tr>
<td>
FRAME 2
<ul>
<li>
<a href="[Link]" target="mainframe">FRUITS</a>
</li>
<li>
<a href="[Link]" target="mainframe">FLOWERS</a>
</li>
<li>
<a href="[Link]" target="mainframe">CITIES</a>
</li>
</ul>
</td>
<td>
FRAME 3<BR>
<iframe name="mainframe"></iframe>
</td>
</tr>
</table>
</body>
</html>

Page 29 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

c Write a javascript to create a pull-down menu with three options [Google, 6M


MSBTE, Yahoo] once the user will select one of the options then user will be
redirected to that site.
Ans <html> pull-down
<head> menu code:
<title>HTML Form</title> 2M each
<script language="javascript" type="text/javascript">
function getPage(choice)
{
page=[Link][[Link]].value;
if(page != "")
{
[Link]=page;
}
}
</script>
</head>
<body>
<form name="myform" action="" method="post">
Select Your Favourite Website:
<select name="MenuChoice" onchange="getPage(this)">
<option
value="[Link]
<option
value="[Link]
<option
value="[Link]
</form>
</body>
</html>

Page 30 |3 0
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2022 EXAMINATION
Subject Name: Client-Side Scripting Model Ans Subject Code: 22519
Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may
vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based
on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual
(English + Marathi) medium is introduced at first year of AICTE diploma Programme from academic year
2021-2022. Hence if the students in first year (first and second semesters) write answers in Marathi or
bilingual language (English +Marathi), the Examiner shall consider the same and assess the answer based
on matching of concepts with model answer.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) State the use of method in javascript with the help of suitable example. 2M

Ans A method/function is a set of statements that take inputs, do some specific computation, Explanation
and produce output. The idea is to put some commonly or repeatedly done tasks together - 1 M and
and make a function so that instead of writing the same code again and again for different Example-
1 M.
inputs, we can call that function.

Example:
function Addition (number1, number2)
{
return number1 + number2;
}
b) List & Explain datatypes in JavaScript. 2M

Ans JavaScript provides different data types to hold different types of values. There are two Any four,
types of data types in JavaScript, Primitive data type and Non-primitive data type ½ for each
i) There are five types of primitive data types in JavaScript. They are as follows:
String - represents sequence of characters e.g., "hello"
Number - represents numeric values e.g., 100
Page No: 1 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Boolean - represents boolean value either false or true
Undefined - represents undefined value
Null - represents null i.e., no value at all

ii) The non-primitive data types are as follows:


Object - represents instance through which we can access members
Array - represents group of similar values
RegExp - represents regular expression
c) Write a simple calculator program using switch case in JavaScript. 2M

Ans <html> 2 M for


<body> relevant
<script> program.
const number1 = parseFloat(prompt("Enter first number: "));
const number2 = parseFloat(prompt("Enter second number: "));

const operator = prompt("Enter operator ( either +, -, *, / or %): ");


let result;

switch (operator) {
case "+":
result = number1 + number2;
[Link](result);
break;
case "-":
result = number1 - number2;
[Link](result);
break;

case "*":
result = number1 * number2;
[Link](result);
break;

case "/":
result = number1 / number2;
[Link](result);
break;

case "%":
result = number1 % number2;
[Link](result);
break;

Page No: 2 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

default:
[Link]("Invalid operator");
break;
}
</script>
</body>
</html>
d) Write a program using sort method of array object. 2M

Ans <html> 2 M for


<body> relevant
<script> program.
var array =[5,1,9,7,5];
// sorting the array
sorted = [Link]();
[Link](sorted);
</script>
</body>
</html>
e) Describe property Getters & Setters. 2M

Ans JavaScript object accessors are used to access and update the objects. Getter and setter are 1 m for each
used as object accessors to get or set object properties.

Getter method helps in accessing the object methods as object properties.

Setter method is used to set object properties.

Using getter and setter the javascript provides better data security and data quality.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var car = {
brand: "Toyota",
color: "Blue",

get getBrand () {
return [Link];
},
get getColor () {
return [Link];

Page No: 3 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
},

set setBrand (newBrand) {


[Link] = newBrand;
},
set setColor (newColor) {
[Link] = newColor;
}
};

[Link]("Car Brand: " + [Link] + "<br>Car Color: " + [Link]);

[Link] = "Tesla";
[Link] = "Red";
[Link]("<br><br>Car Brand: " + [Link] + "<br>Car Color: " +
[Link]);
</script>
</body>
</html>
f) Enlist & explain the use of any two Intrinsic JavaScript Functions. 2M

Ans An intrinsic function (or built-in function) is a function (subroutine) available for use in a 1 M for
given programming language whose implementation is handled specially by the compiler. each
You can use intrinsic functions to make reference to a data item whose value is derived function
automatically during execution.

abs() - The ABS function returns the absolute value of the argument.

sin() - The SIN function returns a numeric value that approximates the sine of the angle or
arc specified by the argument in radians.

sqrt() - The SQRT function returns a numeric value that approximates the square root of
the argument specified.

Date(): return current date.

Len(): returns number of characters in the text.

parseInt() - parseInt() function takes string as a parameter and converts it to integer.

parseFloat() - parseFloat() function takes a string as parameter and parses it to a floating


point number.

g) Describe browser location object. 2M

Page No: 4 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans i) The location object contains information about the current URL. Explanation
ii) The location object is a property of the window object. 1M
iii) The location object is accessed with: [Link] or just location. Example-
Example: 1M
<!DOCTYPE html>
<html>
<body>
<h1>The Window Location Object</h1>
<p id="demo"></p>
<script>
let origin = [Link];
[Link]("demo").innerHTML = origin;
</script>
</body>
</html>

2. Attempt any THREE of the following: 12 M

a) Write a JavaScript program that will display current date in DD/MM/YYYY format. 4M

Ans <!DOCTYPE html> Any


relevant
<html lang="en"> code 4 M.

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>

<script>

var d=new Date();

var currentDate=[Link]()+'/'+([Link]()+1)+'/'+[Link]()

[Link](currentDate)

Page No: 5 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
</script>

</body>

</html>

b) Write a JavaScript program that will remove the duplicate element from an array. 4M

Ans <!DOCTYPE html> Any


<html lang="en"> relevant
<body> code 4 M.
<script>
let arr = ["scale", "happy", "strength", "peace", "happy", "happy"];
function removeDuplicates(arr) {
let unique = [];
for (i = 0; i < [Link]; i++) {
if ([Link](arr[i]) === -1) {
[Link](arr[i]);
}
}
return unique;
}
[Link](removeDuplicates(arr));
</script>
</body>
</html>
c) Write a JavaScript program that will display list of student in ascending order 4M
according to the marks & calculate the average performance of the class.

Student Name Marks


Amit 70
Sumit 78
Abhishek 71

Ans <html> Any


relevant
<body> code 4 M.

<script>

var students = [["Amit", 70],["Sumit", 78],["Abhishek", 71],];

var Avgmarks = 0;

for (var i = 0; i < [Link]; i++) {

Page No: 6 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Avgmarks += students[i][1];

for (var j = i + 1; j < [Link]; j++) {

if (students[i] > students[j]) {

a = students[i];

students[i] = students[j];

students[j] = a

var avg = Avgmarks / [Link];

[Link]("Average grade: " + Avgmarks / [Link]);

[Link]("<br><br>");

for (i = 0; i < [Link]; ++i){

[Link](students[i]+"<br>")

</script>

</body>

</html>

d) Write and explain a string functions for converting string to number and number to 4M
string.

Ans To covert string to number we can use parseInt() which converts a string number to a Any
integer number. Similarly we can use parseFloat(), number() for converting string to relevant
number. code with
explanation
Eg- 4 M.
var a=prompt('Enter a number');
var b=parseInt(prompt('Enter a number'));
[Link](typeof a+"<br>");
[Link](typeof b);
To convert form number to string we can use toString()
<html>
Page No: 7 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<body>
<p>toString() returns a number as a string:</p>
<script>
let num = 12;
let text = [Link]();
[Link](num)
</script>
</body>
</html>

3. Attempt any THREE of the following: 12 M

a) Differentiate between concat( ) & join( ) methods of array object. 4M

Ans Any 4
concat() join() point=4M
The concat() method concatenates (joins) two The join() method returns an array as
or more arrays. a string.
The concat() method returns a new array,
containing the joined arrays.
The concat() method separates each value with Any separator can be specified. The
a comma only. default is comma (,).
Syntax: Syntax:
[Link](array2, array3, ..., arrayX) [Link](separator)
Example: Example:
<script> <script>
const arr1 = ["CO", "IF"]; var fruits = ["Banana", "Orange",
const arr2 = ["CM", "AI",4]; "Apple", "Mango"];
const arr = [Link](arr1, arr2); var text = [Link]();
[Link](arr); [Link](text);
</script> var text1 = [Link]("$$");
[Link]("<br>"+text1);
</script>

b) Write a JavaScript function to check the first character of a string is uppercase or 4M


not.

Ans <html> Correct


<body> function
<script> logic=4M
function upper_case(str)
{
regexp = /^[A-Z]/; (any other
if ([Link](str)) relevant
{
[Link]("String's first character is uppercase");
Page No: 8 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
} logic can
else consider)
{
[Link]("String's first character is not uppercase");
}
}
upper_case('Abcd');
</script>
</body>
</html>

OR
<script>
function firstIsUppercase(str)
{
if ([Link] === 0)
{
return false;
}

return [Link](0).toUpperCase() === [Link](0);


}

if (firstIsUppercase(prompt("Enter text")))
{
[Link]('First letter is uppercase');
} else {
[Link]('First letter is NOT uppercase');
}
</script>

c) Write a JavaScript function to merge two array & removes all duplicate 4M
values.
Ans <html> Correct
<body> function
<script> logic=4 M
function merge_array(array1, array2)
{
var result_array = []; (any other
relevant
var arr = [Link](array2);
logic can
var len = [Link]; consider)
var assoc = {};

Page No: 9 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
while(len--)
{
var item = arr[len];

if(!assoc[item])
{
result_array.unshift(item);
assoc[item] = true;
}
}

return result_array;
}
var array1 = [1, 2, 3,4,7,9];
var array2 = [2, 30, 1,40,9];
[Link](merge_array(array1, array2));
</script>
</body>
</html>

Output:
3,4,7,2,30,1,40,9

OR

<html>
<body>
<script>
function mergearr(arr1, arr2)
{
// merge two arrays
var arr = [Link](arr2);
var uniqueArr = [];
// loop through array
for(var i of arr) {
if([Link](i) === -1)
{
[Link](i);
}
}
[Link](uniqueArr);
}
Page No: 10 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
var array1 = [1, 2, 3,6,8];
var array2 = [2, 3, 5,56,78,3]
mergearr(array1, array2);
</script>
</body>
</html>

Output:
1,2,3,6,8,5,56,78

d) Write a JavaScript function that will open new window when the user will 4M
clicks on the button.
Ans <html> Correct
<body> function
<button onclick="openWin()">Open "New Window"</button> logic=4 M
<script>
var myWindow;
function openWin()
{
myWindow = [Link]("", "myWindow", "width=400,height=400");
[Link]("<p>Hello [Link] to new window.</p>");
}
</script>
</body>
</html>

4. Attempt any THREE of the following: 12 M

a) Describe text Rollover with the help of example. 4M

Ans Rollover means a webpage changes when the user moves his or her mouse over an object Define
on the page. It is often used in advertising. There are two ways to create rollover, using Rollover-2
plain HTML or using a mixture of JavaScript and HTML. We will demonstrate the creation M
of rollovers using both methods.

The keyword that is used to create rollover is the <onmousover> event.


Example-2
For example, we want to create a rollover text that appears in a text area. The text “What M
is rollover?” appears when the user place his or her mouse over the text area and the
(For
rollover text changes to “Rollover means a webpage changes when the user moves his or
example,
her mouse over an object on the page” when the user moves his or her mouse away from
any other
the text area.
relevant

Page No: 11 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The HTML script is shown in the following example: logic can be
considered)
Example:
<html>
<head></head>
<Body>
<textarea rows="2" cols="50" name="rollovertext" onmouseover="[Link]='What
is rollover?'"
onmouseout="[Link]='Rollover means a webpage changes when the user moves
his or her mouse over an object on the page'"></textarea>
</body>
</html>

b) Write a JavaScript program that will create pull-down menu with three 4M
options. Once the user will select the one of the options then user will redirected
to that website.

Ans <html> Creation of


<head> pull-down
<title>HTML Form</title> menus-1 M
<script language="javascript" type="text/javascript">
function getPage(choice)
{ Correct
page=[Link][[Link]].value; function to
if(page != "") redirect
{ particular
[Link]=page; website-3 M
}
}
</script>
OR
</head>
<body>
<form name="myform" action="" method="post">
Select Your Favourite Website: any other
<select name="MenuChoice" onchange="getPage(this)"> relevant
<option value="select any option">Select</option> logic can be
<option value="[Link] considered
CodeAcademy </option>
<option value="[Link]
<option value="[Link]
</form>
</body>
</html>

Page No: 12 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Output:

c) Describe Quantifiers with the help of example. 4M

Ans The frequency or position of bracketed character sequences and single characters can be Describe
denoted by a special character. Each special character has a specific connotation. Quantifiers-
The +, *, ?, and $ flags all follow a character sequence. 2M
For
[Link]. Expression & Description
Example-2
p+ M
1
It matches any string containing one or more p's.
p*
2
It matches any string containing zero or more p's.
p?
3
It matches any string containing at most one p.(zero or one occurrences)
p{N}
4
It matches any string containing a sequence of N p's
p{2,3}
5
It matches any string containing a sequence of two or three p's.
p{2, }
6
It matches any string containing a sequence of at least two p's.
p$
7
It matches any string with p at the end of it.
Example:
<html>
<body>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction()
{
var str = "100, 1000 or 10000?";
var patt1 = /\d{3,4}/g;

Page No: 13 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
var result = [Link](patt1);
[Link]("demo").innerHTML = result;
}
</script>
</body>
</html>
d) Describe frameworks of JavaScript & its application. 4M

Ans Frameworks of JavaScript: Any 2


1. ReactJs
React is based on a reusable component. Simply put, these are code blocks that can be (1m for
classified as either classes or functions. Each component represents a specific part of a explanation
page, such as a logo, a button, or an input box. The parameters they use are called props, and 1M for
which stands for properties. application)

Applications:
React is a JavaScript library developed by Facebook which, among other things, was used
to build [Link].

2. Angular
Google operates this framework and is designed to use it to develop a Single Page
Application (SPA). This development framework is known primarily because it gives
developers the best conditions to combine JavaScript with HTML and CSS. Google
operates this framework and is designed to use it to develop a Single Page Application
(SPA). This development framework is known primarily because it gives developers the
best conditions to combine JavaScript with HTML and CSS.

Applications:
Microsoft Office ,Gmail, Forbes, PayPal, Grasshopper, Samsung, Delta

3. [Link]
Vue is an open-source JavaScript framework for creating a creative UI. The integration
with Vue in projects using other JavaScript libraries is simplified because it is designed to
be adaptable.

Application:
VueJS is primarily used to build web interfaces and one-page applications. It can also
be applied to both desktop and mobile app development.

4. jQuery
It is a cross-platform JavaScript library designed to simplify HTML client-side scripting.
You can use the jQuery API to handle, animate, and manipulate an event in an HTML
document, also known as DOM. Also, jQuery is used with Angular and React App building
tools.
Applications:
1. JQuery can be used to develop Ajax based applications.
2. It can be used to make code simple, concise and reusable.
3. It simplifies the process of traversal of HTML DOM tree.
4. It can also handle events, perform animation and add ajax support in web applications.
Page No: 14 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

5. [Link]
[Link] is an open-source, server-side platform built on the Google Chrome JavaScript
Engine. [Link] is an asynchronous, single-threaded, non-blocking I/O model that makes
it lightweight and efficient.
Applications:
Paypal, LinkedIn, Yahoo, Mozilla, Netflix, Uber, Groupon, GoDaddy, eBay

e) Describe how to link banner advertisement to URL with example. 4M

Ans The banner advertisement is the hallmark of every commercial web page. It is typically Banner-1 M
positioned near the top of the web page, and its purpose is to get the visitor's attention by Example-3
doing all sorts of clever things. M
To get additional information, the visitor is expected to click the banner so that a new web
page opens. You can link a banner advertisement to a web page by inserting a hyperlink
into your web page that calls a JavaScript function rather than the URL of a web page. The
JavaScript then determines the URL that is associated with the current banner and loads the
web page that is associated with the URL.

Example:
<html>
<head>
<title>Link Banner Ads</title>
<script language="Javascript" type="text/javascript">
Banners = new Array('[Link]','[Link]','[Link]')
BannerLink = new Array(
'[Link]/','[Link]/', '[Link]/');
CurrentBanner = 0;
NumOfBanners = [Link];
function LinkBanner()
{
[Link] =
"[Link] + BannerLink[CurrentBanner];
}
function DisplayBanners() {
if ([Link]) {
CurrentBanner++
if (CurrentBanner == NumOfBanners) {
CurrentBanner = 0
}
[Link]= Banners[CurrentBanner]
setTimeout("DisplayBanners()",1000)
}
}
</script>
</head>
<body onload="DisplayBanners()" >
<center>
<a href="javascript: LinkBanner()"><img src="[Link]"
Page No: 15 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
width="400" height="75" name="RotateBanner" /></a>
</center>
</body> </html>

5. Attempt any TWO of the following: 12 M

a) Write HTML script that will display following structure 6M

Write the JavaScript code for below operations:


(1) Name, Email & Pin Code should not be blank.
(2) Pin Code must contain 6 digits & it should not be accept any characters.
Ans <html> Creation of
<head> correct form
<style> and calling
table,tr,td event-2 M
{
border: solid black 1px;
border-collapse: collapse;
Name,
}
Email and
Pin code
td
should not
{
be blank-2
padding: 10px;
M
}
</style>
</head>
<body>
<table>
<tbody> Pin code
<tr> must
<td>Name : </td> contain 6
<td> <input type="text" id="name" required></td> digits and it
</tr> should not
<tr> be blank-2
<td>Email : </td> M
<td> <input type="email" id="email" required></td>
</tr>
<tr>

Page No: 16 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<td>Pin code : </td>
<td> <input type="number" id="pin" required></td>
</tr>
<tr>
<td></td>
<td><button onclick="submit()">Submit</button></td>
</tr>
</tbody>
</table>
</body>
<script>
function submit()
{
var name = [Link]("name").value;
var email = [Link]("email").value;
var pin = Number([Link]("pin").value);
if([Link]==0 || [Link]==0 || [Link]==0)
{
alert("Please enter value in all fields.")
}
else
{
var pinpattern =/^[4]{1}[0-9]{5}$/;
if( [Link](pin))
{
alert("Perfect Pin code");
}
else
{
alert("Wrong Pin code.");
}
}
}
</script>
</html>

b) Write a webpage that displays a form that contains an input for user name and 6M
password. User is prompted to enter the input user name and password and password
becomes the value of the cookie. Write the JavaScript function for storing the cookies.
It gets executed when the password changes.
Ans <html> Creation of
<head> form=2 M
<script> Storing and
function storeCookie() display
{ cookie
var pwd = [Link]('pwd').value information-
[Link] = "Password=" + pwd + ";" 4M

Page No: 17 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
alert("Cookie Stored\n"+[Link]);
}
</script>
</head>
<body>
<form name="myForm">
Enter Username <input type="text" id="uname"/><br/>
Enter Password <input type="password" id="pwd"/><br/>
<input type="button" value="Submit" onclick="storeCookie()"/>
<p id="panel"></p>
</form>
</body>
</html>

c) Write a JavaScript for creating following frame structure: 6M

Chapter 1 and Chapter 2 are linked to the webpage [Link] and [Link]
respectively. When user click on these links corresponding data appears in
FRAME3.
Ans Step 1) create file [Link] Correct
<html> frameset
<body> logic=6 M
<h1 align="center">FRAME1</h1>
</body>
</html> OR
( any other
relevant
Step 2) create [Link]
logic can be
<html> considered )
<head>
<title>FRAME 2</title>
</head>
<body><H1>Operating System</H1>
<a href="[Link]" target="c"><UL>Chapter 1</UL></a>
<br>
<a href=" [Link]" target="c"><UL> Chapter 2</UL></a>
</body>
</html>

Page No: 18 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Step 3) create [Link]
<html>
<body>
<h1>FRAME3</h1>
</body>
</html>

Step4) create frame_target.html


<html>
<head>
<title>Create a Frame</title>
</head>
<frameset rows="30%,*" border="1">
<frame src="[Link]" name="a" />
<frameset cols="50%,*" border="1">
<frame src="[Link]" name="b" />
<frame src="[Link]" name="c" />
</frameset>
</frameset>
</html>

Output:

6. Attempt any TWO of the following: 12 M

a) Write HTML script that will display dropdown list containing options such as 6M
Red, Green, Blue and Yellow. Write a JavaScript program such that when the
user selects any options. It will change the background colour of webpage.

Page No: 19 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans <html> Creation of
<body> list-2 M
<label for="color">Choose a Background Color:</label>
<select name="color" id="color" class="color" onchange="changeColor()"> Correct
<option value="red">Red</option> logic to
<option value="green">Green</option> Change
<option value="blue">Blue</option> background
<option value="yellow">Yellow</option> color as per
</select> selection-4
<script type="text/javascript"> M
function changeColor() {
var color = [Link]("color").value;
switch(color){
case "green":
[Link] = "green";
break;
case "red":
[Link] = "red";
break;
case "blue":
[Link] = "blue";
break;
case "yellow":
[Link] = "yellow";
break;
default:
[Link] = "white";
break;
}
}
</script>
</body>
</html>
b) Develop a JavaScript program to create Rotating Banner Ads. 6M

Ans <html > Correct


<head> logic-6 M
<title>Banner Ads</title>
<script>
Banners = new Array('[Link]','[Link]','[Link]'); OR
CurrentBanner = 0; ( any other
function DisplayBanners() relevant
{ logic can be
if ([Link]); considered )
{
CurrentBanner++;
if (CurrentBanner == [Link])
{
CurrentBanner = 0;

Page No: 20 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
[Link]= Banners[CurrentBanner];
setTimeout("DisplayBanners()",1000);
}
}
</script>
</head>
<body onload="DisplayBanners()" >
<center>
<img src="[Link]" width="400"
height="75" name="RotateBanner" />
</center>
</body>
</html>

c) Write a JavaScript for the folding tree menu. 6M

Ans <html> Correct


<head> logic-6 M
<style>
ul, #myUL {
list-style-type: none;
OR
}
( any other
.caret::before {
relevant
content: "\25B6";
logic can be
color: black;
considered )
display: inline-block;
margin-right: 6px;
}

.caret-down::before {
-ms-transform: rotate(90deg); /* IE 9 */
-webkit-transform: rotate(90deg); /* Safari */'
transform: rotate(90deg);
}

.nested {
display: none;
}

.active {
display: block;
}
</style>
</head>
<body>

<h2>Folding Tree Menu</h2>


<p>A tree menu represents a hierarchical view of information, where each item can have a
number of subitems.</p>
Page No: 21 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<p>Click on the arrow(s) to open or close the tree branches.</p>

<ul id="myUL">
<li><span class="caret">India</span>
<ul class="nested">
<li>Karnataka</li>
<li>Tamilnaadu</li>
<li><span class="caret">Maharashtra</span>
<ul class="nested">
<li>Mumbai</li>
<li>Pune</li>
<li><span class="caret">Navi Mumbai</span>
<ul class="nested">
<li>Nerul</li>
<li>Vashi</li>
<li>Panvel</li>

</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<script>
var toggler = [Link]("caret");
var i;
for (i = 0; i < [Link]; i++) {
toggler[i].addEventListener("click", function() {
[Link](".nested").[Link]("active");
[Link]("caret-down");
});
}
</script>
</body>
</html>

Page No: 22 | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2023 EXAMINATION
Model Answer – Only for the Use of RAC Assessors

Subject Name: Client Side Scripting Subject Code:


22519
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the model answer22519
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
XXXXX
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures
drawn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with model
answer.
9) For programming language papers, in answer session comments and output is not required.
Q. Sub Answer Marking
No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) State meaning of each token of the following statement and describe 2M


it:
i) ++a;
ii) document. bgcolor;

Ans (i) ++ is the increment operator and a is the operand, hence a++ will increment the Anyone
value of a by 1. explained - 1
M each.
(ii) The bgColor property specifies the background color of HTML document.
b) Write and explain syntax of prompt( ) method in JavaScript. 2M

Ans  prompt() method is used to display a dialogue box to the user to prompt them to Definition- 1
an input. M

 It has two buttons “OK” and “CANCEL”, if the user click on the “OK” button Syntax- 1 M
then it will return the inputed value , if the user clicks on the "CANCEL” button
then it will return a null value

 Syntax: prompt(text)

Page No: 1 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
 Example:
<script>
var name = prompt ("Enter a name");
document. Write(name);
</script>
c) List various assignment operators supported by JavaScript, explain any 2M
two with the help of suitable example.
Ans assignment operators supported by JavaScript List – 1 M
Operators Meaning Explain any 2
= Equal to -1M
+= Plus Equal to
-= Minus Equal to
/= Divide Equal to
%= Modulus Equal to
*= Multiply Equal to

Example:
<script>
// = is used to assign a value to a variable
var num = 10;
[Link](num); // num 10
/* += first add the value to the existing value of the variable then assign it the new added
value */
num +=10; [Link](num); // num 20
</script>
d) Differentiate between shift() and push() methods of an Array object. 2M

Ans Any two


points- 1 M
shift push each
1. shift method is used to delete the first 1. push method is used to insert zero or
element of an existing array more element at the end of an existing
array
2. Syntax: 2. Syntax:
[Link](); [Link](element1,element2,…,elementn);
3. Example: 3. Example:
<script> <script>
var arr = [1,2,3,4]; var arr = [1,2,3,4];
[Link](arr); [Link](arr);
[Link](); [Link](5,6);
[Link](arr); [Link](arr);
</script> </script>

Page No: 2 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
e) State the meaning of "Defining a function". Explain with the help of an example. 2M

Ans  A function is a block of code that takes some input to perform some certain Explanation-
computation. 1M

 The main purpose of the function is to put commonly used or repeatedly used Example- 1
task in a function, so instead of writing the code again and again we can call it M
instead.

 The function can be defined as followed:

Syntax:
function func_name(parameter1 ,parameter2,…,parametern)
{
//code
}
Example:
<script>
function add(num1,num2)
{
return num1 + num2;
}
add(1,2);
</script>
f) Give syntax of and explain the use of small “with” clause. 2M

Ans “with” clause is used to directly access the properties and method of an object. Explanation-
1M
Syntax:
with (object) Syntax- 1 M
{
//object
}
Example:
<script>
var person ={ name:"Abc", age:18
}
with(person){ [Link](name); [Link](age);
}
</script>
g) With the help of suitable example explain the Date object and any two methods of 2M
Date object.

Ans “Date” object is used when we want to perform some operation on date, it has various Explanation-
method which helps you performs some task related to date, 1M
Example: Example- 1

Page No: 3 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<script> M
var date = new Date();
[Link]([Link]()); // get the current date
[Link]([Link]()); // get the current Year
[Link]([Link]()); // get the current minutes
</script>

2. Attempt any THREE of the following: 12 M

a) Write a JavaScript that accepts a number and displays addition of digits 4M


of that number in a message box.
Ans <html> Relevant
<body> code- 4 M
<script>
var num = prompt(“Enter a 2 digit number:”); //accept number from user
var digits = [Link]();
var firstdigit = Integer(digits[0]);
var seconddigit = Integer(digits[1]);
var addition = firstdigit+seconddigit;
alert(“The addition is “+addition); //display result in message box
</script>
</body>
</html>
b) Describe the navigator object in JavaScript. Describe the methods of 4M
navigator object which is used to display browser name and version.
Ans  Navigator object is a representation of user’s browser. Explanation -
 Navigator is an object of window. 2M
 Methods of navigator object- Only one method is supported by Navigator
Object. Method – 2
i) javaEnabled()- returns true if the browser has java enabled. M
• We use appName to display browser name. appName is a property of navigator.
• appName property returns browser name.
• We use appVersion to display browser version. appVersion is a property of
navigator.
• appVersion property returns browser version.
• Example:-
<html>
<body>
<script>
[Link](“Browser name: “+[Link]); [Link](“Browser
Version: “+[Link]);
</script>

Page No: 4 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
</body>
</html>
c) Give syntax of and explain for-in loop in javascript with the help of suitable 4M
example.

Ans For-in Loop: Explanation -


2M
Syntax:-
Syntax – 1 M
For(x in object){
Example-1 M
//code to be executed
}

 For-in loop is used to loop through the properties of an object.


 In syntax, variable represents the property name, and object is the object being
iterated.
 It's handy for tasks like accessing or manipulating object properties.
Example:-
<html>
<body>
<script>
Var car = { Brand: ‘Toyota’, Model: ‘Camry’, Year: 2022
};
For( key in car){ [Link](‘${key}: ${car[key]}’);
}
</script>
</body>
</html>
d) Write an HTML script that accepts Amount, Rate of interest and Period 4M
from user. When user submits the information a JavaScript function must
calculate and display simple interest in a message box. (Use formula S.I. =
PNR/100)

Ans <html> Relevant


code- 4 M
<body>
<script>
var P = parseInt(prompt(“Enter the principal amount:”));
var N = parseInt(prompt(“Enter the period:”));
var R = parseInt(prompt(“Enter the Rate of interest:”));
var SI =(P*N*R)/100;
alert(“Simple Interest is “+SI);

Page No: 5 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
</script>
</body>
</html>

OR
<html>
<head>
<script>

function interest()
{
var P, N, R;
P= parseInt([Link]("pr").value);
N = parseInt([Link]("period").value);
R = parseInt([Link]("ri").value);
var SI =(P*N*R)/100;
alert("Simple Interest is="+SI);
}
</script>
</head>
<body>
<p>Principal Amount:<input id="pr"></p>
<p>Period in Year: <input id="period"></p>
<p>Rate of Interst: <input id="ri"></p>
<button onclick="interest()"> Simple Interest</button>
</body>
</html>

Output:

Page No: 6 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
3. Attempt any THREE of the following: 12 M

a) Write an HTML Script that displays the following webpage output: Designing
and calling
function in
onClick() -
1M

Writing
function for
add,sub,mul-
03M
The user enters two numbers in respective text boxes. Write a JavaScript
such that when user clicks "add", a message box displays sum of two entered
numbers, if the user clicks on "sub”. Message box displays subtraction of two
numbers and on clicking “mul” the message box displays multiplication of
two numbers.

Ans <html>
<head>
<script>
function add()
{
var num1, num2, r;
//to accept 2 values and stored in variable num1 and num2
num1 = parseInt([Link]("firstnumber").value);
num2 = parseInt([Link]("secondnumber").value);
r= num1 + num2;
alert(r);
}
function sub()
{
var num1, num2, r;
num1 = parseInt([Link]("firstnumber").value);
num2 = parseInt([Link]("secondnumber").value);

Page No: 7 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
r = num1 - num2;
alert(r);
}
function mul()
{
var num1, num2, r;
num1 = parseInt([Link]("firstnumber").value);
num2 = parseInt([Link]("secondnumber").value);
r = num1 * num2;
alert(r);
}
</script>
</head>
<body>
<fieldset>
<p>First Number: <input id="firstnumber"></p>
<p>Second Number: <input id="secondnumber"></p>
//onClick() event to perform addition, subtraction and multiplication
<button onclick="add()">Add</button>
<button onclick="sub()">Sub</button>
<button onclick="mul()">Mul</button>
</fieldset>
</body>
</html>

Output:

Page No: 8 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

b) Write a JavaScript that accents user's first name and domain name of 4M
Organization from user., The JavaScript then forms email address as
<firstname@domain> name and displays the results in the browser window.

Ans <html> Accept


values-1M
<head>
Formation of
<script> email id-2M
//Email Address Function Calling
function in
function myemail()
onClick()-1M
{
var s1 = [Link]("first").value;
var s2 = [Link]("domain").value;
var s3=s1+"@"+s2;
[Link]("email").innerHTML = s3;
}
</script>
</head>
<body>
<p>First Name: <input id="first"></p>
<p>Domain Name: <input id="domain"></p>
<button onclick="myemail()">create email id</button>
<br> Email ID is
<p id="email"> </p>
</body>
</html>

Page No: 9 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Output:

c) Differentiate between substring() and substr() method of a string class. Give 4M


Suitable example of each.

Ans Parameters substring() substr()

Use It is used to extract the It is used to extract a part of 3 points-3M


specified substring within a the string Example-1M
string

Syntax [Link](start, end); [Link](start, len);

Parameters Its parameters are the start It takes parameters as starting


and end position of the index of the part which we
substring that we want to want to extract and the length
extract. till which we want to extract
the string part.

index This method cannot handle This method can handle


negative indexes. negative indexes.

Example:
<script>
var a="Javascript";
[Link]("Using substring()="+[Link](2,6));
[Link]("<br>Using substr()="+[Link](2,6));
</script>

Output:
Using substring()=vasc
Using substr()=vascri
d) State what is a cookie? Explain its need. State characteristics of persistent 4M
cookies.

Page No: 10 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Cookie: Definition-1M
Cookies are small text files that websites use to store information on a user's computer
or device. Cookies can be used for a variety of purposes, such as remembering a user's Need-1M
preferences, tracking their behavior on a website, and enabling personalized advertising.
Charactristics-
There are two main types of cookies: session cookies and persistent cookies. 2M

Need of Cookie:
Cookies are built specifically for web browsers to track, personalize and save
information about each user's session. A “session” is the word used to define the amount
of time you spend on a site. Cookies are created to identify you when you visit a new
website.

Characteristics of persistent cookies:


 Persistent cookies can be used to store information that needs to be accessed
across multiple browsing sessions, such as login credentials and language
preferences.

 Persistent cookies can be used to track a user's behavior on a website over time,
which can be used to personalize the user's experience.

 Persistent cookies can be used to remember a user's preferences, such as their


preferred layout or font size.

4. Attempt any THREE of the following: 12 M

a) Write a JavaScript that accepts a string and searches for the pattern 4M
"MSBTE" in the given string using regular expressions. If the pattern is
found, JavaScript will display that "Pattern is found" else display "Pattern is
not found".

Ans <html> Accept string-


<head> 1M
<title>JavaScript RegExp exec Method</title>
</head> Correct
<body> RegEx-2M
<script type = "text/javascript">
Condition
var str= prompt("Enter a string");
checking-1M
var re = new RegExp( "MSBTE", "g" );
var result = [Link](str);
if(result=="MSBTE")
{
[Link]("pattern is found");
}
else
{
[Link]("pattern is not found");
}
Page No: 11 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
</script>
</body>
</html>
b) List and state various properties of a window object. Write a JavaScript that 4M
opens a new popup window with message WELCOME To SCRIPTING"
when the page loads and a new popup window displaying message "FUN
WITH SCRIPTING when the page unloads.

Ans Window Object Properties properties of a


window
Property Description object-1M

Document It returns the document object for the window (DOM).


Frames It returns an array of all the frames including iframes in the current calling onload
window. ()-1M

Closed It returns the Boolean value indicating whether a window has been
closed or not.
calling
History It returns the history object for the window. onunload()-
1M
innerHeight It sets or returns the inner height of a window's content area.
innerWidth It sets or returns the inner width of a window's content area.
valid function
Length It returns the number of frames in a window.
definition-1M
Location It returns the location object for the window.
Name It sets or returns the name of a window.
Navigator It returns the navigator object for the window.
Opener It returns a reference to the window that created the window.
outerHeight It sets or returns the outer height of a window, including
toolbars/scrollbars.
outerWidth It sets or returns the outer width of a window, including
toolbars/scrollbars.
Parent It returns the parent window of the current window.
Screen It returns the screen object for the window.
screenX It returns the X coordinate of the window relative to the screen.
screenY It returns the Y coordinate of the window relative to the screen.
Self It returns the current window.
Status It sets the text in the status bar of a window.
Top It returns the topmost browser window that contains frames.

Page No: 12 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Code:
<html>
<body onload="openWin()" onunload = "[Link]("FUN WITH
SCRIPTING");">

<script>
var myWindow;
function openWin()
{
myWindow = [Link]("", "myWindow", "width=200,height=100");
[Link]("<p>WELCOME TO SCRIPTING</p>");
}
function closeWin()
{
[Link]();
alert("Fun with SCripting");
}
</script>
</body>
</html>
Output:

c) Write an HTML script that displays names of different brands of Laptop and 4M

an image by default as :

When the mouse moves over the specific brand name the script must display the
image of respective Laptop in the adjacent box.
Ans Code: Designing of
form-1M
<html>
<head> Any relevant
Page No: 13 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<title> logic-3M
text rollovers</title>
<script>
b=new Image;
r=new Image;
g=new Image;
if([Link])
{
[Link]='[Link]';
[Link]='[Link]';
[Link]='[Link]';
}
else
{
[Link]='';
[Link]='';
[Link]='';
[Link]='';
}

</script>
</head>
<body>
<table border="0" width="100%">
<tbody>
<tr valign="top">

<td><H2><ul><li>
<a onmouseover="[Link]='[Link]'">
<b><u>Lenovo</u></b></a></li>
<li><a onmouseover="[Link]='[Link]'">
<b><u>HP</u></b></a></li>
<li><a onmouseover="[Link]='[Link]'">
<b><u>DELL</u></b></a></li></ul>
</H2>
</td>
<td width="50%">
<a><img height="200" src="[Link]" width=400" name="clr"></a></td>
</tr>
</tbody>
</table>
</body>
</html>

Output:
When mouse over to HP, hp laptop image will displayed.

Page No: 14 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

d) Give syntax of and explain the use of SetTimeOut() function with the help of 4M
suitable example.

Ans
Use of setTimeout() Use of
SetTimeOut()-
The setTimeout() method executes a block of code after the specified time. The method 1M
executes the code only once.
Syntax-1M
The commonly used syntax of JavaScript setTimeout is: Example-2M

setTimeout(function, milliseconds);

Its parameters are:

 function - a function containing a block of code


 milliseconds - the time after which the function is executed

The setTimeout() method returns an intervalID, which is a positive integer.

Example: Display a Text Once After 3 Second

<script>
function greet()
{
[Link]('Hello world');
}
setTimeout(greet, 3000);
[Link]('This message is shown first');
</script>

Page No: 15 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
In the above program, the setTimeout() method calls the greet() function after 3000
milliseconds (3 second).
Hence, the program displays the text Hello world only once after 3 seconds.
e) State the use of hiding the JavaScript. Explain the steps needed to accomplish it and 4M
describe the process.

Ans You can hide your JavaScript from a visitor by storing it in an external file on your web Use-2M
server. The external file should have the .js file extension. The browser then calls the
external file whenever the browser encounters a JavaScript element in the web page. If Steps with
you look at the source code for the web page, you'll see reference to the external .js file, code-2M
but you won't see the source code for the JavaScript.

[Link]
<html>
<head>
<script src="[Link]" languages="javascript" type="text/javascript">
</script>
<body>
<h3> Right Click on screen, Context Menu is disabled</h3>
</body>
</html>
[Link]
[Link]=function()
{
[Link]("contextmenu", function(e)
{
[Link]();
}, false);
}

5. Attempt any TWO of the following: 12 M

a) Write a JavaScript that demonstrates use of floating menu alongwith 6M


respective HTML script.

Ans Code: Any relevant


<html> logic or
<title>Example</title> example-6M
<style>
body {
background-image: url('/pix/samples/[Link]');
}
main {
margin-bottom: 200%;
}
.floating-menu {
Page No: 16 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
font-family: sans-serif;
background: yellowgreen;
padding: 5px;;
width: 130px;
z-index: 100;
position: fixed;
}
.floating-menu a,
.floating-menu h3 {
font-size: 0.9em;
display: block;
margin: 0 0.5em;
color: white;
}
</style>
<main>
<p>Scroll down and watch the menu remain fixed in the same position, as though it
was floating.</p>
<nav class="floating-menu">
<h3>Floating Menu</h3>
<a href="c_sub.txt">C</a>
<a href="C++_sub.txt">C++</a>
<a href="java_sub.txt">Java</a>
<a href="python_sub.txt">Python</a>
</nav>
</main>

Output:

b) Form regular expressions for following : 6M

Page No: 17 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
i) Validation of email address.

ii) Validation of adhaar card. Format is

dddd - dddd - dddd

(iii) Validation of phone number. Format is

(ddd) -(dddddddd)

Ans i) Regular expression for Validation of email address: Any valid


regex for
var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0- emailed-2M
9-]+)*$/;
Any valid
regex for
ii) Validation of adhaar card Format is adhaar card-
dddd - dddd – dddd 2M
Any valid
Regular expression for Validation of adhaar card
regex for
/^[2-9]{1}[0-9]{3}\s[0-9]{4}\s[0-9]{4}$/gm
phone no-2M

iii) Validation of phone number. Format is


(ddd) -(dddddddd)

Regular expression for Validation of phone number:

var re = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im;s

Page No: 18 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) 6M

Ans Code: Designing of


<html> form-2M
<body>
<html> Any relevant
<script type="text/javascript"> script-4M
function modifyList(x)
{
with([Link])
{
if(x ==1)
{
optionList[0].text="Green Tea";
optionList[0].value=1;
optionList[1].text="Milk Tea ";
optionList[1].value=2;
optionList[2].text="Black Tea";
optionList[2].value=3;
}

if(x ==2)
{
optionList[0].text="Capaccino";
optionList[0].value=1;
Page No: 19 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
optionList[1].text="Latte";
optionList[1].value=2;
optionList[2].text="Expression";
optionList[2].value=3;
}
if(x ==3)
{
optionList[0].text="MAAZA";
optionList[0].value=1;
optionList[1].text="SPRITE";
optionList[1].value=2;
optionList[2].text="COKA-COLA";
optionList[2].value=3;
}

}
}

</script>
</head>
<body>
<form name="myform" action=" " method="post">
<table><tr><td>
Select Beverage: </td><td>
<input type="checkbox" name="grp1" value=1 checked="true"
onclick="modifyList([Link])"> TEA

<input type="checkbox" name="grp1" value=2 onclick="modifyList([Link])">


COFFEE
<input type="checkbox" name="grp1" value=3 onclick="modifyList([Link])">
SOFT DRINK

</td></tr></table>
<select name="optionList" size="3">
<option value=1>Kiwi
<option value=1>Pine-Apple
<option value=1>Apple
</tr> </table>
</select>
</form>
</body>
</html>

Output:

Page No: 20 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

6. Attempt any TWO of the following: 12 M

a) List and explain any six form events. 6M

Ans One event


with
Event Handler Description explanation-
1M each
onfocus When the user focuses on an element
onsubmit When the user submits the form
onblur When the focus is away from a form element (The onblur event
occurs when an object loses focus.)
onchange When the user modifies or changes the value of a form element
keydown The event occurs when the user is pressing a key
keypress The event occurs when the user presses a key
keyup The event occurs when the user releases a key
onclick Fires on a mouse click on the element
ondblclick Fires on a mouse double-click on the element
onmousedown Fires when a mouse button is pressed down on an element
onmousemove Fires when the mouse pointer is moving while it is over an element
onmouseout Fires when the mouse pointer moves out of an element
onmouseover Fires when the mouse pointer moves over an element
onmouseup Fires when a mouse button is released over an element
onwheel Fires when the mouse wheel rolls up or down over an element
oncontextmenu oncontextmenu event occurs when the user right-clicks on an
element to open the context menu.

b) Write a JavaScript that sets a crawling status bar message to the webpage. 6M
Message is "Welcome to the Mystic World of JavaScript". The message must
start crawling when the webpage gets loaded.

Ans <html> Any relevant


<head> script-6M
<title>Scrolling Text</title>
<script language="JavaScript">
var scrollPos = 0; // initial position to start status bar
var maxScroll = 100; // maximum allowed position
Page No: 21 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
var blanks = "";
function scrollText(text, milliseconds)
{
[Link]("displayText('"+text+"')", milliseconds);
}
function displayText(text)
{
[Link] = blanks + text;
++scrollPos;
blanks += " ";
if(scrollPos > maxScroll)
{
scrollPos = 0;
blanks = "";
}
}
</script>
</head>
<body onload="scrollText(‘Welcome to the Mystic World of JavaScript".’, 300)">
<p>Watch the text scroll at the bottom of this window!</p>
</body>
</html>
c) i)Design frameset tag for representing following layout: 6M

ii) List any three properties of regular expression objects and state their use.
Ans i) i) correct html
code-3M
Code:
ii) 3 properties
<html> with use-3M
<head> each
<title>Create a Frame</title>
</head>
<frameset rows="10%,*" border="5" frameborder="1" bordercolor="red" noresize>
<frame src="[Link]">
<frameset cols="33%,33%,*" border="3">
<frame src="[Link]">
<frame src="[Link]">
Page No: 22 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<frame src="[Link]">
</frameset>
</frameset>
</html>

ii)

property Property & Description

constructor Specifies the function that creates an object's


prototype.
global
Specifies if the "g" modifier is set.

ignoreCase
Specifies if the "i" modifier is set.

lastIndex
The index at which to start the next match.

multiline
Specifies if the "m" modifier is set.

source
The text of the pattern.

Example:
<html>
<head>
<title>JavaScript RegExp ignoreCase Property</title>
</head>
<body>
<script type = "text/javascript">
var re = new RegExp( "string" );

if ( [Link] )
{

Page No: 23 | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
[Link]("Test1-ignoreCase property is set");
} else
{
[Link]("Test1-ignoreCase property is not set");
}

re = new RegExp( "string", "i" );

if ( [Link] )
{
[Link]("<br/>Test2-ignoreCase property is set");
} else
{
[Link]("<br/>Test2-ignoreCase property is not set");
}
</script>
</body>
</html>

Page No: 24 | 24

Common questions

Powered by AI

Non-preemptive scheduling allows a process to hold the CPU until it terminates or switches to waiting state, resulting in lower scheduling overhead and simpler management. However, it can cause lower responsiveness to high-priority tasks. Preemptive scheduling, by contrast, allows processes to be interrupted and moved to the ready queue to meet the needs of high-priority tasks, improving responsiveness but increasing overhead for context switching. The implication for system performance is that preemptive scheduling can better handle priorities and yield better overall system responsiveness at the cost of increased complexity .

Operating systems in distributed environments manage network bandwidth through a variety of strategies, such as implementing traffic shaping to prioritize certain types of data, utilizing load balancing to distribute network load evenly across servers, and applying quality of service (QoS) protocols to guarantee a baseline level of performance for critical applications. These strategies ensure efficient usage of network resources, allowing for consistent and reliable network performance despite variable demand and external conditions .

Error detection and handling functionalities are crucial in maintaining an operating system's reliability and security. These functions allow the system to identify, report, and manage errors efficiently, minimizing disruptions through recovery procedures. Advanced error handling mechanisms can detect potential security vulnerabilities before they are exploited, safeguarding system integrity. However, improper error detection can lead to system instability or unaddressed security vulnerabilities, underscoring the need for robust and comprehensive error management protocols .

Operating systems use system calls for process and job control to manage and manipulate the execution of processes. Examples include system calls like 'Create Process', which initiates a new process, 'Terminate Process' to end a process, and 'Wait' for a process's execution to halt until a certain condition is met. These calls are essential for multitasking, enabling processes to be created, managed, and terminated systematically, ensuring efficient CPU utilization and process hierarchy maintenance .

The primary challenge of contiguous file allocation is finding enough contiguous blocks of storage to place a file during its creation. This is difficult because it requires searching a free space list for the required number of contiguous blocks, which can become increasingly fragmented over time as files are created and deleted. The operating system addresses these issues through various strategies, like defragmentation, which involves reorganizing the contents of the storage device to place available free blocks together, thereby simplifying the allocation process .

Memory compaction addresses fragmentation by rearranging memory contents so that free memory is consolidated into a single large block, making it easier to allocate memory for large processes without splitting them. However, its limitations include the high overhead associated with moving processes in memory, which can lead to performance degradation, especially in systems with large and numerous processes. It is also not a solution for the fragmented nature of storage itself, only for volatile RAM .

User interfaces in operating systems serve as the primary point of interaction between the user and the system's hardware. They significantly enhance user experience by providing intuitive and accessible means to execute commands and manage processes, such as through graphical interfaces or command-line prompts. However, potential drawbacks include increased complexity and resource requirements for graphical interfaces, which can lead to slower system performance or require more powerful hardware. Additionally, the reliance on intuitive interfaces can obscure deeper system functionality, limiting users' understanding of underlying processes .

Virtual memory enables systems to use disk space to simulate additional RAM, allowing for larger programs and multitasking without requiring equivalent physical memory capacities. The benefits include increased flexibility, efficient process isolation, and better utilization of system resources. However, challenges arise in terms of performance overhead due to swapping and paging, which can slow down systems if not managed properly. Virtual memory can greatly impact system performance negatively through increased latency unless optimized with adequate algorithms to manage task prioritization and memory swapping .

Time-sharing operating systems allocate CPU time to multiple users by dividing it into time slots, minimizing response time for individual tasks and allowing multiple users to interact with the system simultaneously. Conversely, multiprogramming operating systems prioritize maximizing CPU utilization by enabling multiple programs to reside in memory and ensuring that the CPU is never idle, thus addressing processor and memory underutilization. The advantage of time-sharing is enhanced user interaction and minimal response time. In contrast, multiprogramming's advantage lies in its efficiency in resource utilization, reducing idle time for processors .

File manipulation services enhance operating system usability by allowing users to create, modify, delete, and manage files efficiently. These services support numerous operations such as reading, writing, appending data, and repositioning within files, providing a flexible interface for data management. For example, renaming files and directories allows for better organization, while file copying aids in data redundancy and safety. These functionalities streamline user interaction with the filesystem, promoting a versatile and productive computing environment .

You might also like