Il 83% ha trovato utile questo documento (6 voti)
3K visualizzazioni16 pagine

CSSL Soln

CSS solution

Caricato da

Wajid Ansari
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato PDF o leggi online su Scribd
Il 83% ha trovato utile questo documento (6 voti)
3K visualizzazioni16 pagine

CSSL Soln

CSS solution

Caricato da

Wajid Ansari
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato PDF o leggi online su Scribd
Sei sulla pagina 1/ 16
TY, Diploma : Sem. V - Elective [co/cm/cw/TF] Client Side Scripting Language Time: 3 Hes.) Prelim Question Paper Solution Marks : 70 Q.1 Attempt any FIVE of the following : (10) Q.1(a) State the use of dot syntax in JavaScript with the help of suitable example. (2) Ans.: In JavaScript, one can access properties using the dot notation. Dot notation allows us to tell instance of a class to use one of the methods inside that class. For eg, car.name Q.1(b) List and explain Logical operators in JavaScript. (a ‘Ans.i Assume variable A holds 10 and variable B holds 20, then - ‘Operator & Description (0 [&& (Logical AND) ITF both the operands are non-zero, then the condition becomes true. JEx: (A && B) is true. (ii) | (Logical OR) ITF any of the two operands are non-zero, then the condition becomes true. Ex: (A 11 8) is true. Gi) |! Cogical NOT) Reverses the logical state of its operand. If a condition is true, then the Logical NOT| loperator will make it false. JEx:1(A 6d B) is false. Q.1(c) Write a JavaScript that identifies a running browser. (a Ans.

what is your Browser Application name?

«

scrip document getElementById("p1").innerHTML = “Browser Application name is: " + navigator.appName; document getElementById("p2").innerHTML = "Browser Application code name isi * " + navigator.appCodeName: document getElementById("p2").innerHTML = “Browser version is: " + navigator.appVersion; Q.1(d) Write a JavaScript that initializes an array called “Fruits” with names of five (2] fruits. The script then displays the array in a message box. Ans.

The length property returns the length of an array.

htm Q.1(e) Give syntax of and explain the use of “with” statement/clause in JavaScript using [2] suitable example. ‘Ans.: The ‘with’ statement adds the given object to the head of this scope chain during the evaluation of its statement body. If an unqualified name used in the body matches a property in the scope chain, then the name is bound to the property and the object containing the property. Otherwise a ReferenceError is thrown, Syntax: with (expression) statement Example: function f(foo, values) { with (foo) { document.write(values); ) } Q.1(F) Enlist and explain the use of any two Intrinsic JavaScript functions. ica) Ans.: abs() Returns the absolute value of a number. exp) Returns EN, where N is the argument, and E is Euler's constant, the base of the natural logarithm. Q.1(g) State and explain what is a session cookie ? 2 ‘Ans.i © A session cookie contains information that is stored ina temporary memory — location and then subsequently deleted after the session is completed or the web browser is closed. This cookie stores information that the user has inputted and tracks the movements of the user within the website. + The main difference between a session and a cookie is that session data is stored on the server, whereas cookies store data in the visitor's browser. Sessions are more secure than cookies as it is stored in server Q.2__ Attempt any THREE of the following fz} Q.2(a) What are javaScript Accessors (setters and getters)? 4] Ans.: © Getters and setters exist in most object-oriented programming languages, including JavaScript. + They are code constructs that help developers access the properties of objects in a secure way. + With getters, you can access ("get") the values of properties from external code, while setters let you change ("set") their values + Itgives simpler syntax. + Ttallows equal syntax for properties and methods. + Itcan secure better data quality * A TavaScript object can have multiple properties and methods that store static data ‘and dynamic functionality. Properties are static key-value pairs, while metheds are functions specific to the object Prelim Question Paper Solution + For example, Car.color could be a property, while Car.drive() could be a method of the Carobject. With a getter, you can access the color property of the Car object and with a setter, you can modify its value (for instance, from blue to black), + To get the properties of the Car object, you need to call the getter methods. Example: var obj = { Ex: ‘this is the value of foo", get€x: function() ( return this.Ex; ) setEx: function(val) { this.Ex = val; ) ) console.log(obj.getEx()): // "this is the value of obj setEx(‘hello’): foo" console.log(obj.getEx()): 17 “hello” Q.2(b) Write a JavaScript program which compute, the average marks of the following [4] students Then, this average is used to determine the corresponding grade. Ans.: student Name ‘Marks ‘Advait 80 ‘Anay 77 ‘Manyata 88 ‘Saanvi 95 ‘Saachi 68 Ranae | Grade <60 «70 <80 <90) <100) > |o|a Jo} Q.2(c) Write a JavaScript that displays all properties of window object. Explain the [4] code. scrip var myWindow: function openWin() ( myWindow=window.open("', "myWindow’, “width=200, height=100"): myWindow.document.write("

This is new Windows/p>"); } function moveWin() { myWindow.moveTo(500, 100); myWindow.Focus(): ) Prelim Question Paper Solution

Q.5(b) Write a webpage that diplays a form that contains an input for Username and [6] password. User is prompted to enter the input and password and password becomes value of the cookie. Write The JavaScript function for storing the cookie . It gets executed when the password changes. Ans.: -13- Vidyalankar : T.Y. Diploma - OS
Name:
Password:
Q.5(c) Write a script for creating following frame structure : 6) Ans.: FRAME 1 FRAMEZ FRAMES © FRUITS * FLOWERS + CITIES Fruits, Flowers and Cities are links to the webpage fruits.html, flowers.html, cities.html respectively. When these links are clicked corresponding data appears in “FRAMES”. FRAME 1 ‘te an “tb FRAME 2 “fruits.html" targe "mainframe"»*FRUITS lowers html" target="mainframe"»FLOWERS CITIES
atd> FRAME 3
-14- Qe Prelim Question Paper Solution Attempt any TWO of the following : 2) Q.6(a) Write HTML Script that displays dropdownlist containing options NewDelhi, [6] Ans.: ‘Mumbai, Bangalore. Write proper JavaScript such that when the user selects any options corresponding description of about 20 words and image of the city appear in table which appears below on the same page «form «select name="Select City">
You have selected New Delhi so i am here “dive
Q.6(b) Write a JavaScript function to hide email addresses to protect from unauthorized [6] Ans.: user. protect_email = function (user_email) { var avg, splitted, part1, part2: splitted = user_email split("@"); part! = splitted[O} artl.length / 2: part! = partl.substring(0, (part length - avg)): part2 = splitted{1} return partl + "..@" + part2; } console.log(protect_email("[email protected]")): Output: [email protected] Q.6(c) Create a slideshow with the group of four images, also simulate the next and [4] ‘Ans.: previous transition between slides in your JavaScript. '200" alt="" height="300" name="imgl"/> ‘Next onclick="SlideShow(1)"> "Back" onclick="SlideShow(-1)"> gooaa = 16 -

Potrebbero piacerti anche