Вы находитесь на странице: 1из 33

QN=1 (2726) a. b. c. d. QN=2 (2928) a. b. QN=3 (2724) a. b. c. d. QN=4 (2713) a. b. c. d. QN=5 (2934) a. b. QN=6 (2926) a. b. QN=7 (2930) a. b.

QN=8 (2929) a. b. QN=9 (2931) a. b.

Which of these characters can be included within the text in an XML document in literal form? > ; : XML parser checks for validity and well formed ness? True False Which of the following is/are optional in the creation of an XML file? The <?xml version="1.0"?> statement The root element The opening tag in an element Entities Which of the following XML attribute names is invalid? _notvalid I am not valid not-valid.1 _not1valid2 A descendant having a new namespace cannot override the namespace defined by the parrent element? true false Parameter entities use ampersand (&) and semicolon (;) as delimiters? true false XML developer has to ensure the uniqueness of the element names and attributes in a document? true false XML is transformed only via XSLT? true false Browser has the ability distinguish duplicate element names in an XML document? true false

QN=10 (2725) a. b. c.

Which of these is a valid comment in XML? <!-This is a sample XML document> <?This is a sample XML document?> <!- -This data should be hidden <FIRSTNAME>Joe</FIRSTNAME> <LASTNAME>Johnson</LASTNAME> - -> <?--This is a sample XML document--> What does the keyword SYSTEM indicate in the following code? <?xml version =1.0?> <!DOCTYPE Book SYSTEM book.dtd> It is a system generated DTD Book.dtd is an internal DTD Book.dtd is an external DTD Book is a system variable Which of the following statements is not true? The <!DOCTYPE [] > declaration follows the XML declaration Entities that appear anywhere in an XML document are referred to as Parameter entities Attributes are added to an element to provide information about the element Entities must be declared within the document DOCTYPE declaration Which of the following is not a keyword used for default settings in an! ATTLIST element? #IMPLIED #DEFINE #REQUIRED #FIXED External DTDs use the keyword URL to specify the location of the DTD? true false The question mark (?) operator indicates either zero or one occurrence. any number of occurrences. one or more occurrences. more than one occurrence. For each element type associated with a sequence element, there must be an element in the XML instance in the same order? true false

d. QN=11 (2731) a. b. c. d. QN=12 (2728) a. b. c. d. QN=13 (2718) a. b. c. d. QN=14 (2938) a. b. QN=15 (2717) a. b. c. d. QN=16 (2945) a. b.

QN=17 (2948) a. b. c. d. QN=18 (2918) a. b. QN=19 (2920) a. b. c. QN=20 (2944) a. b. QN=21 (2771) a. b. c. QN=22 (2760) a. b. c. d. QN=23 (2763) a. b. QN=24 (2738) a. b. c. d.

Specifies that the attribute cannot be used? prohibited required optional use An XML Schema defines whether an element is empty or can include text. true false In schema, the ALL element requires that each element in the group must occur at most once there must be an element in the XML instance in the same order the maxOccurs attribute can be 0 or 1 The default value for the minOccurs attribute in Schema is 0 true false See the snipset below and choose one answer: <xsl:value-of select=floor(-2.3)/> -2 -2.5 -3 Which top level XSLT elements is used to define a variable in a stylesheet or template and to assign it a value xsl:include xsl:output xsl:variable xsl:text Xpath can be thought of as a query language like SQL True False Which of these is the correct syntax to link an XSL file to an XML document? <?xmls type="text/xsl" href="candidate.xsl"?> <?xml-stylesheet type="text/xsl" href="candidate.xsl"?> <?xsl type="text/xsl" href="candidate.xsl"?> <?xml:xsl href="candidate.xsl"?>

QN=25 (2901) a. b. c. d. QN=26 (2889) a. b. c. d. QN=27 (2773) a. b. QN=28 (2897) a. b. c. d. QN=29 (2893) a. b. c. d. QN=30 (2737) a. b. c. d. QN=31 (2747) a. b. c. QN=32 (2951) a.

CSS positions can be either absolute or ________. Static relative transferred Disabled ________ are declared in each individual HTML element using the keyword STYLE. Cascading style sheets Inline styles External styles User style sheets XSLT takes two things as input: an XSLT stylesheet and an xml input document True false What is the significance of the following CSS rule? LI, EM { color: red;cfont-weight: bold } It will apply the specified style to text enclosed by either LI or EM tags. It will apply the specified style to text enclosed by the EM tags which are within LI tags. It will apply the specified style to text enclosed by the LI tags which are within EM tags. It will apply the specified style to text not enclosed by either LI or EM tags. Which of the following selections is the proper way to apply this CSS rule: .blue { color: blue } <P COLOR = "blue"> <P CLASS = "blue"> <P COLOR = .blue> <P CLASS = .blue> In CSS, when a style is applied to an element containing other elements inside it The style is applied to the element and all the other elements contained in it The style is applied only to the main element The style is applied only to the child elements The user is prompted with a message enquiring whether the style is to be applied to the child elements as well In DOM, a node can have More than one parent nodes More than one children nodes No sibling nodes Tree model is applied to static documents? true

b. QN=33 (2754) a. b. c. d. QN=34 (2739)

false Method hasChildNodes of XMLDOMNode mean Determine if a given node is empty or not Determine if a given node has child nodes or not Determine if a given node and all descendants has been parsed and instantiated Return an integer representing the XML DOM node type With reference to the snippet of code given below, choose the correct syntax to complete the second line in order to create a XML Document Object var sample sample = ________________________ CreateXMLDocument() new ActiveXObject("microsoft.XMLDOM") NewXMLDocument New XMLDOMObject Which object represents the top level of the XML source? XML DOMParent DOMDocument None of them In SAX, to provide customized DTD handling, application need to implement ErrorHandler DTDHandler EntityResolver DefaultHandler SAX uses Pull parsing machenic for processing Push parsing machenic for processing A in memory data structure for processing The StAX cursor API represents a cursor with which you can walk an XML document from beginning to end. an XML document stream as a set of discrete event objects. an object - based tree in computer memory SAX support random access True False

a. b. c. d. QN=35 (2740) a. b. c. d. QN=36 (2753) a. b. c. d. QN=37 (2746) a. b. c. QN=38 (2923) a. b. c. QN=39 (2751) a. b.

QN=40 (2756) a. b. c. d. QN=41 (2819) a. b. c. d. QN=42 (2880) a. b. c. d. QN=43 (2857) a. b. c. d. QN=44 (2788) a. b. c. d. QN=45 (2811) a. b. c. d. QN=46 (2812) a. b. c. d.

Method characters() of ContentHandler interface receives events for The begining of element Character data The end of element The begining of document What is the value of num after the following statement is performed? num = Math.round( 2.45 ); 0 2 2.5 3 What does the value string contain after the following code is executed? var string = "Good luck on the test"; string = string.link("www.deitel.com") a link to www.deitel.com with the text "www.deitel.com" a link to www.deitel.com with the text "Good luck on the test" the text "www.deitel.com" Nothing, the string conversion will generate an error. To divide the value of the seventh element of array a by 2 and assign the result to the variable x, we would write ________. x / 2 = a( 7 ) x = a[ 7 ] / 2 x = a[ 6 ] / 2 x = a( 6 / 2 ) A procedure for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed is called ________. program control a program structure a control structure an algorithm Which of the following is not required for counter-controlled repetition? final value initial value Sentinel Increment What is wrong with the following line of code? <P><FONT SIZE='5'>This is a test.</FONT></P> Nothing There is no attribute named SIZE for the element FONT The value 5 must not be placed within quotes The value 5 must be placed within double quotes

QN=47 (2908) a. b. c. d. QN=48 (2790) a. b. c. d. QN=49 (2871) a. b. c. d. QN=50 (2881)

Which of the following statements regarding filters and transitions is false? They are built into Internet Explorer. They are applied on a client computer at run time by the server. They enable portions of pages and entire pages to be faded in an out. They enable 3-d effects. A program in which all statements are executed one after the other in the order in which they are written exhibit ________. transfer of control Algorithms sequential execution direct execution ________ and ________ run slower when they are applied to large arrays. linear search, binary search linear search, bubble sort binary search, bubble sort linear bubble search, binary - linear sort What is the value of s3 after the following code is executed? var s1 = one, s2 = two, s3 = three; s1.concat(s2) s3 = s1; One Onetwo Three Onetwothree

a. b. c. d.

For Examination Department Only Answer of Paper Code=IS321_XML_070610 *************************************************************** [id=2726, Mark=1]1. BCD ABC [id=2928, Mark=1]2. A [id=2724, Mark=1]3. D [id=2713, Mark=1]4. B [id=2934, Mark=1]5. B [id=2926, Mark=1]6. B [id=2930, Mark=1]7. A [id=2929, Mark=1]8. B [id=2931, Mark=1]9. B [id=2725, Mark=1]10. C [id=2731, Mark=1]11. C [id=2728, Mark=1]12. B [id=2718, Mark=1]13. B [id=2938, Mark=1]14. B [id=2717, Mark=1]15. A [id=2945, Mark=1]16. A [id=2948, Mark=1]17. A [id=2918, Mark=1]18. A [id=2920, Mark=1]19. A [id=2944, Mark=1]20. B [id=2771, Mark=1]21. C [id=2760, Mark=1]22. C [id=2763, Mark=1]23. A [id=2738, Mark=1]24. B [id=2901, Mark=1]25. B [id=2889, Mark=1]26. B [id=2773, Mark=1]27. A [id=2897, Mark=1]28. A [id=2893, Mark=1]29. B [id=2737, Mark=1]30. A [id=2747, Mark=1]31. B [id=2951, Mark=1]32. B [id=2754, Mark=1]33. B [id=2739, Mark=1]34. B [id=2740, Mark=1]35. C [id=2753, Mark=1]36. B [id=2746, Mark=1]37. B [id=2923, Mark=1]38. A [id=2751, Mark=1]39. B [id=2756, Mark=1]40. B [id=2819, Mark=1]41. B [id=2880, Mark=1]42. B

[id=2857, Mark=1]43. C [id=2788, Mark=1]44. D [id=2811, Mark=1]45. C [id=2812, Mark=1]46. A [id=2908, Mark=1]47. B [id=2790, Mark=1]48. C [id=2871, Mark=1]49. B [id=2881, Mark=1]50. B *************************************************************** Chapter 8 JavaScript/JScript: Introduction to Scripting 8.1 Microsoft's version of scripting that uses the Java syntax is called ________. a) JavaScript b) JScript c) ECMAScript d) J++ 8.2 ________ was originally created by ________. a) JScript, Netscape b) JScript, ECMA c) JavaScript, Microsoft d) JavaScript, Netscape 8.3 The default scripting language for Netscape and Internet Explorer is ________. a) JavaScript b) Perl c) ECMAScript d) Python 8.4 In the following line, the word document is a ________ which resides in the computers memory and contains information used by the script. document.writeln("Hello World"); a) attribute b) behavior c) object d) method 8.5 In the following line, the word writeln is a ________ which performs a task or action in the script. document.writeln("Hello World"); a) structure b) collection c) object d) method

8.6 Consider the following HTML code. <HTML> <SCRIPT LANGUAGE = "JavaScript"> <!-document.writeln("Hello World"); // --> </SCRIPT> </HTML> What would a browser capable of scripting display when executing this code? a) document.writeln("Hello World"); b) nothing c) Hello World d) <HTML> <SCRIPT LANGUAGE = "JavaScript"> <!-document.writeln("Hello World"); // --> </SCRIPT> </HTML> Ans: c) 8.7 The line window.alert("Hello world") will display output in ________. a) a dialog box b) the HTML document c) the Debug window d) the status bar 8.8 The \n,\t, \r escape sequences do not affect HTML rendering unless they are used between which tags? a) <SELECT></SELECT> b) <SCRIPT></SCRIPT> c) <PRE></PRE> d) <A></A> 8.9 Consider the following script. What is wrong with the following code? 1 <SCRIPT LANGUAGE = "JavaScript"> 2 var firstNumber, 3 secondNumber; 4 thirdNumber; 5 6 thirdNumber = 7 parseInt( window.prompt( "Enter an integer", 0 ) ); 8 document.write( thirdNumber ); 9 </SCRIPT> a) thirdNumber in line 8 must be in quotes.

b) The words Enter an integer in line 7 should not be in quotes. c) The word var must be placed before secondNumber in line 3. d) The word var must be placed before thirdNumber in line 4. 8.10 What would the browser display if the following script was executed and the user entered 5 at both prompts? 1 <SCRIPT LANGUAGE = "JavaScript"> 2 var firstNumber = window.prompt("Enter an integer", 0); 3 var secondNumber = window.prompt("Enter an integer",0); 4 var thirdNumber; 5 thirdNumber = firstNumber + secondNumber; 6 document.write( thirdNumber ); 7 </SCRIPT> a) nothing b) 0 c) 10 d) 55 8.11 What is the result of the statement 17 % 5? a) 0 b) 2 c) 3 d) 12 8.12 Which of the following selections does not follow the rules of operator precedence. Assume that the operators on the left are evaluated first. a) multiplication, division, addition b) parentheses, subtraction, modulus c) division, multiplication, addition d) parentheses, modulus, subtraction . 8.13 What is the evaluation of the following expression? ((3+ ( 5 + 4 ) * 7 ) + 4 ) / 5 a) 8 b) 14 c) 17.6 d) 26.4 8.14 Which of the following is not a valid equality or relational operator? a) = b) < c) > d) !=

Chapter 9: JavaScript/JScript: Control Structures I 9.1 A procedure for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed is called ________. a) program control b) a program structure c) a control structure d) an algorithm 9.2 ________ is an artificial and informal language that helps programmers develop algorithms. a) JavaScript b) ECMAScript c) Pseudocode d) AlgorithmCode 9.3 A program in which all statements are executed one after the other in the order in which they are written exhibit ________. a) transfer of control b) algorithms c) sequential execution d) direct execution 9.4 Which of the following contradicts the notion of structured programming? a) if b) for/in c) goto d) while 9.5 The word sequence in the term sequence structure refers to the sequence of ________. a) bits in a JavaScript instruction b) JavaScript instructions in a script c) scripts in a HTML file d) HTML files in a Web site 9.6 Which of the following is not one of Bohm and Jacopini's three control structures? a) goto-less structure b) sequence structure c) selection structure d) repetition structure 9.7 Which of the following flowchart symbols indicates that a decision is to be made? a) diamond b) oval/circle

c) rectangle d) flowline 9.8 Which of the following is not a JavaScript selection structure? a) if/else b) for/in c) switch d) if 9.9 Which of the following is a JavaScript repetition structure? a) while/repeat b) do/while c) do/repeat d) for/do 9.10 Which of the following is not a JavaScript keyword? a) break b) delete c) sub d) function 9.11 Which of the following statements is correct? a) If ( studentGrade >= 60 ) document.writeln( "Passed" ); b) if ( studentGrade >= 60 ); document.writeln( "Passed" ); c) if ( studentGrade >= 60 ) document.write( "Passed" ); d) If ( studentGrade >= 60 ); document.write( "Passed" ); 9.12 What would the browser display if the following code is executed in a script? var x = 11, y = 14; if ( x > 13 ) if ( y > 13 ) document.writeln( "x and y are > 13" ); else document.writeln( "x is <= 13" ); a) nothing, the code will generate an error b) 11 c) x and y are > 13 d) x is <= 13 Ans: d) 9.13 What would the browser display if the following code is executed in a script? var grade = 59

if ( grade >= 60 ) document.writeln( "Passed." ); else document.write( "Failed. " ); document.writeln( "You must take this course again." ); a) Passed. b) Failed. c) You must take this course again. d) Failed. You must take this course again. 9.14 What would the browser display if the following code was executed in a script? var product = 0; while ( product <= 25 ); product = 2 + product; a) nothing, the script would result in an error b) 0 c) 25 d) 26 9.15 What would the browser display if the following script is executed? <SCRIPT LANGUAGE = "JavaScript"> var count = 0, total = 0; while ( count <= 5 ) { total = total + 10; count = count + 1; } document.write(total); </SCRIPT> a) Nothing, the browser would generate an error. b) 0 c) 50 d) 60 9.16 What would the browser display if the following script is executed? <SCRIPT LANGUAGE = "JavaScript"> var count = 5, total = 0; while ( count > -1 ) { total = total 10; count = count 1; } document.write(total); </SCRIPT> a) Nothing, the browser would generate an error. b) 0

c) -50 d) -60 9.17 If the string passed to parseInt contains a floating-point numeric value, parseInt will ________. a) return NaN b) return 0 c) round the value to the nearest tenth d) truncate the floating-point part 9.18 If the string passed to parseInt contains text characters, parseInt will ________. a) return NaN b) return 0 c) return the sum of the characters' ASCII values d) truncate the text entries 9.19 What type of loop is shown in the script below? <SCRIPT LANGUAGE = "JavaScript"> var gradeValue = 0, total = 0, grade = 0; while ( gradeValue != - 1 ) { total = total + gradeValue; grade = window.prompt( "Enter Integer Grade, -1 to Quit:", "0"); gradeValue = parseInt( grade ); } </SCRIPT> a) count controlled b) sentinel controlled c) algorithm controlled d) stepwise controlled 9.20 The word top in the term top-down stepwise refinement refers to which of the following? a) the first statement that appears in the program b) the first statement that appears in the algorithm c) the single statement that completely represents the program d) the entire algorithm 9.21 What is the value of i after the following statements? i = 2; i += 25; a) 25

b) 27 c) 50 d) 52 9.22 What is the value of i after the following statements? i = 2; i++; a) 0 b) 2 c) 3 d) 4 9.23 What is the value of i after the following statements? i = 2; i--; i--; a) 0 b) 1 c) -2 d) -4 Chapter 10: JavaScript/JScript: Control Structures II 10.1 Which of the following is not required for counter-controlled repetition? a) final value b) initial value c) sentinel d) increment 10.2 What is wrong with the following line of code? <P><FONT SIZE='5'>This is a test.</FONT></P> a) Nothing b) There is no attribute named SIZE for the element FONT c) The value 5 must not be placed within quotes d) The value 5 must be placed within double quotes 10.3 What would the browser display if the following script was executed? <SCRIPT LANGUAGE = "JavaScript"> for( int i = 0; i < 5; i++ ) document.write("X"); </SCRIPT> a) Nothing, the script would generate an error b) XXXX c) XXXXX d) XXXXXX

10.4 What would the browser display if the following script was executed? <SCRIPT LANGUAGE = "JavaScript"> for( var i = 0; i < 5; i++ ) document.write("O"); </SCRIPT> a) Nothing, the script would generate an error b) OOOO c) OOOOO d) OOOOOO 10.5 Which of the following are declared correctly? a) for (var i=0;i<100;++i ) [ statement; ] b) for (var i=0;i<100;++I ) [ statement; } c) for (var i=0;i<100;++i ) { statement; } d) for (var i=0;i<100;++i; ) { statement; } 10.6 Which of the following is declared correctly and will not result in an error assuming x = 2 and y = 30? a) for ( var j = 10; j <= 80; j-- ) b) for ( var j = x, j <= y, j += 5 ) c) for ( var j = x; j <= 80 * y; j += 5 / x ) d) for ( var j = x; j <= 80 * y; j -= 5 ) 10.7 Which of the following is true? a) for and while structures both increment their counters before the body statement is performed. b) for and while structures both increment their counters after the body statement is performed. c) for loops increment before the body statement is performed and while loops increment after the body statement is performed d) for loops increment after the body statement is performed and while loops increment in either condition or body 10.8 What is the value of num after the following statement is performed?

num = 2 * Math.pow( 2, 3 ); a) 16 b) 18 c) 64 d) 8 10.9 What is the value of num after the following statement is performed? num = Math.round( 2.45 ); a) 0 b) 2 c) 2.5 d) 3 10.10 The ________ multiple selection structure is used to handle multiple decision making and can be used to replace multiple if and if/else statements. a) do/while b) case c) break d) switch 10.11 Every switch structure must have ________ labels which are separated by the keyword break. a) default b) if/else c) case d) choice 10.12 In a switch structure, the ________ case clause is used to process exceptional conditions and is usually listed last. a) break b) default c) else d) then 10.13 Consider the following code selections. Assume count is initialized to 7 and num is initialized to 0. i) ii) do { while ( count < 6 ) num = count; num = count; } while ( count < 6 ) What will the value of num be for i) and ii) respectively after the loops have been executed? a) 0, 0 b) 0, 7

c) 7, 0 d) 7, 7 10.14 What would the browser display if it executed the following script? <SCRIPT LANGUAGE = "JavaScript"> for ( var count = 1; count <= 10; ++count ) { if ( count == 5 ) break; } document.writeln( count ); </SCRIPT> a) Nothing, the script would generate an error. b) 1 c) 5 d) 10 10.15 What would the browser display if it executed the following script? <SCRIPT LANGUAGE = "JavaScript"> for ( var count = 0; count < 10; ++count ) { if ( count == 5 ) continue; } document.writeln( count ); </SCRIPT> a) Nothing, the script would generate an error. b) 1 c) 5 d) 10 10.16 What would the browser display if it executed the following script? <SCRIPT LANGUAGE = "JavaScript"> var total = 0; stop: { // labeled compound statement for ( var i = 0; i < 5; ++i ) { for ( var j = 0; j < 2 ; ++j ) { if ( i == 2 ) break stop; total++; } total++; } total++; } total++; document.writeln( total ); </SCRIPT>

a) 7 b) 8 c) 9 d) 10 10.17 What would the browser display if it executed the following script? <SCRIPT LANGUAGE = "JavaScript"> var total = 0; nextLoop: for ( var i = 0; i < 5; ++i ) { for ( var j = 0; j < 2 ; ++j ) { if ( i < 2 ) continue nextLoop; total++; } total++; } total++; document.writeln( total ); </SCRIPT> a) 7 b) 8 c) 9 d) 10 10.18 Which of the following will not evaluate to true? a) false || false b) true || true c) false || true d) true || false Ans: a) conditions are false. Figure 10.16 is a truth table for the logical OR operator (||). 10.19 Which of the following will evaluate to false? a) false && false b) true && true c) false && true d) true && false 10.20 Which of the following is false? a) In any flowchart, any rectangle (action) can be replaced by 2 rectangle (actions) in sequence. b) In any flowchart, any rectangle (action) can be replaced by any control structure (sequence, if, if/else, switch, while, do/while or for). c) In any flowchart, control structure (sequence, if, if/else, switch, while, do/while or for) can

be replaced by 2 rectangle (actions) in sequence. d) Connecting control structures in sequence is called control structure stacking 10.21 According to Bohm and Jacopini, which of the following does not follow structured programming? a) Stacked building blocks b) Nested building blocks c) Overlapping building blocks d) Invisible building blocks Chapter 11: JavaScript/JScript: Functions 11.1 The best way to develop and maintain a large program is to construct it from small, simple pieces called ________. a) scripts b) modules c) scriptlets d) objects 11.2 The technique of developing and maintaining a large program by constructing it from small, simple pieces is called ________. a) divide and conquer b) modular programming c) multitasking d) multiprogramming 11.3 Modules in JavaScript are called ________. a) subroutines b) routines c) methods d) functions 11.4 The prepackaged functions that belong to JavaScript objects such as Math.pow and Math.round are often called ________. a) subroutines b) routines c) methods d) functions 11.3 Programmer-Defined Functions 11.5 All variables declared in function definitions are ________. a) global variables b) local variables

c) static variables d) constant variables 11.6 Functions are invoked by writing the name of the function, followed by the function's ________ in closed parenthesis. a) name b) static variables c) arguments d) constant variables 11.7 Function definitions often contain ________ which are considered to be local variables and correspond with the arguments in the function call. a) parameters b) static variables c) register variabless d) constant variables 11.8 Which of the following is a legal function call for the function definition provided below? function square( y ) { return y * y; } a) square(7+2); b) square("7"); c) square(7,2); d) square 7; 11.9 What is the result of writing the keyword var in a function parameter list? a) The result would be a JavaScript runtime error. b) The parameter following the keyword would have global scope. c) The parameter following the keyword would have local scope. d) The parameter following the keyword would become a static variable. 11.10 What would the function cube return, assuming it is called with the line cube(3). function cube( y ); { return y * y * y; } a) JavaScript runtime error b) 3 c) 9 d) 27 11.11 What does the following statement do?

Math.floor( Math.random() * 12 ); a) This creates a random number from 0 up to and including 12. b) This creates a random number from 0 up to but not including 12. c) This creates a random number from 1 up to and including 12. d) This creates a random number from 1 up to but not including 12. 11.12 The value a in the following statement is called the ________ and the value b is called the ________. face = Math.floor( a + Math.random() * b ); a) scaling factor, shifting value b) shifting value, scaling factor c) scaling value, shifting factor d) shifting factor, scaling value 11.6 Example: A Game of Chance 11.13 Where on the browser will the command window.status( "text" ) display output? a) in the body b) in an alert dialog box c) in a status dialog box d) on the status bar 11.14 The style of programming in which the user interacts with a GUI component is called ________ programming. a) object-oriented b) automatic c) event-driven d) modular 11.15 If the HTML form game has a text field named point in it, what is the proper way to set the text associated with point to 10? a) game.point = "10" b) game.point.text = "10" c) game.point.caption = "10" d) game.point.value = "10" 11.16 The member access operator is which of the following a) * b) % c) . d) / 11.17 The ________ of a variable is the period during which it exists in memory.

a) scope b) recursion c) duration d) length 11.18 Identifiers that represent local variables in a function ________. a) are globally accessible to the script b) exist while the function in which they are declared is still active c) exist while the function in which they are declared is no longer active d) are not automatically destroyed when the function in which they are declared is exited. 11.19 Local variables have ________ duration. a) local b) global c) automatic d) static 11.20 Identifiers which have static duration ________. a) are globally accessible to the script b) exist while the function in which they are declared is still active c) exist while the function in which they are declared is no longer active d) are not automatically destroyed when the function in which they are declared is exited. 11.21 Script-level variables have ________ duration. a) local b) global c) automatic d) static 11.22 The _______ of an identifier for a variable or function is the portion of the program in which the identifier can be referenced. a) scope b) recursion c) duration d) length 11.23 Giving a local function variable the same name as a global variable will result in which of the following? a) JavaScript runtime error. b) Data corruption. c) The local function variable will rename itself. d) The local variable will "hide" the global variable.

11.24 A function that calls itself either directly or indirectly through another function is called a ________ function. a) base case b) iterative c) recursive d) fibonacci 11.25 Iteration uses ________ structures and recursion uses ________ structures. a) counter - recursive, counter - iterative b) repetition, function calling c) repetition, selection d) function calling, repetition 11.26 When does a recursive process go into an infinite recursion? a) if the loop-continuation test never becomes false b) if the recursion test never becomes false c) if the loop-continuation test never becomes true d) if the recursion step does not converge on the base case Chapter 12: JavaScript/JScript: Arrays 12.1 _________ are data structures consisting of related data items (sometimes called collections of data items). a) lvalues b) composites c) arrays d) databases 12.2 To refer to a particular location or element in the array, we specify the name of the array and the ________ of the particular element in the array. a) contents b) size c) position number d) type 12.3 Which of the following is the proper method to access the length of the array arr[]? a) arr[].length b) arr[subscript].length c) arr.length d) arr(length) 12.4 To divide the value of the seventh element of array a by 2 and assign the result to the variable x, we would write ________.

a) x / 2 = a( 7 ) b) x = a[ 7 ] / 2 c) x = a[ 6 ] / 2 d) x = a( 6 / 2 ) 12.5 Which of the following is the proper method to dynamically allocate memory to an array of 100 elements? a) var c = new c[ 100 ]; b) var c = new c( 100 ); c) var c = new Array[ 100 ]; d) var c = new Array( 100 ); 12.5 Which of the following is the proper method to dynamically allocate memory to an array of 100 elements? a) var c = new c[ 100 ]; b) var c = new c( 100 ); c) var c = new Array[ 100 ]; d) var c = new Array( 100 ); 12.6 The statement on line 1 ________ the array while the statement on line 2 ________ the array. 1 var c; 2 c = new Array( 12 ); a) declares, initializes b) initializes, declares c) declares, allocates d) allocates, declares 12.7 Initializing an array directly involves using the ________ control structure. a) for loop b) new c) function d) dynamic memory allocation operator 12.8 What would the browser display if this script was executed? <SCRIPT LANGUAGE = "JavaScript"> var c = new Array(8) for( var i = 0; i < 8; i++ ) c[i] = i; document.write(c[8]) </SCRIPT> a) undefined b) 0 c) 7

d) 8 12.9 What would the browser display if this script was executed? <SCRIPT LANGUAGE = "JavaScript"> var c = new Array(8) for( var i = 0; i < 10; i++ ) c[i] = i; document.write(c[9]) </SCRIPT> a) undefined b) 0 c) 8 d) 9 12.10 Which of the following is an illegal array initialization statement? a) var n = [ 10, 20, 30, 40, 50 ]; b) var n = new Array( 10, 20, 30, 40, 50 ); c) var n = new Array( 5 ); n = [ 10, 20, 30, 40, 50 ]; d) var n = new Array( 5 ); for ( var i = 1; i <= 5; i++ ) n[ i ] = i * 10 ; 12.11 In the following statement, the range of the variable element is ________. for ( var element in theArray ) total2 += theArray[ element ]; a) 0 to the array length b) 1 to the array length c) 0 to the array length - 1 d) 1 to the array length - 1 12.12 What is the value of num assuming that all 12 elements of array test are initialized to 3? ++test[ 7 ]; var num = test[ 7 ]; a) 3 b) 4 c) 8 d) 10 12.13 In JavaScript, all objects and Arrays are passed to functions by ________. a) value b) parameters c) memory d) reference

12.14 Call-by- ________ is the method of passing a copy of the argument's value to a function. a) value b) parameters c) memory d) reference 12.15 Call-by- ________ is the method of passing the argument's actual location in memory to a function. a) value b) parameters c) memory d) reference 12.16 In JavaScript, numbers and boolean values are passed to functions by ________. a) value b) parameters c) memory d) reference 12.6 Passing Arrays to Functions 12.17 What is the effect of the join statement in the following code? var theArray1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], theArray2 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; var value = theArray1.join( " " ); a) The join method will concatenate the values of theArray2 to theArray1. b) The join method will concatenate the values of theArray1 to theArray2. c) The join method will create a string from the values in theArray1. d) The join method will create a string with the values of theArray2 concatenated to the values of theArray1. 12.18 What will the browser display if the following script is executed? < SCRIPT LANGUAGE = "JavaScript" > var theArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; modifyArray( theArray[ 3 ] ); document.write( theArray.join( " " ) ); function modifyArray( i ) { i = 11; } </SCRIPT> a) Nothing, the browser will generate an error. b) 1 2 3 4 5 6 7 8 9 c) 1 2 11 4 5 6 7 8 9 d) 1 2 3 11 5 6 7 8 9

12.9 Multiple-Subscripted Arrays 12.21 What would the browser output if the following script is executed? < SCRIPT LANGUAGE = "JavaScript" > var array = [ [ 1, 2, 3 ], [ 1, 2, 3 ] ]; for ( var i in array ) { for ( var j in array[ i ] ) document.write( array[ i ][ j ] + " " ); document.writeln("<BR>"); } < /SCRIPT > a) Nothing, the script would generate an error b) 1 2 3 c) 1 2 3 4 5 6 d) 1 2 3 1 2 3 Ans: d) < SCRIPT LANGUAGE = "JavaScript" > var array = [ [ 1, 2, 3 ], [ 1, 2, 3 ] ]; for ( var i in array ) { for ( var j in array[ i ] ) document.write( array[ i ][ j ] + " " ); document.writeln("<BR>"); } < /SCRIPT > a) Nothing, the script would generate an error b) 1 2 3 c) 1 2 3 4 5 6 d) 1 2 3 1 2 3 Chapter 13: JavaScript/JScript Objects 13.2 Thinking About Objects 13.1 Each object has ________ or data and ________ or behavior. a) properties, attributes b) attributes, properties c) attributes, methods d) methods, attributes Ans: c) 13.2 Which of the following is false? a) Programs communicate with objects by using well-defined interfaces. b) Objects do not have the property of information hiding. c) Browsers have a set of objects that encapsulate the HTML document. d) Characters are the building blocks of JavaScript programs. Ans: b) 13.3 An object's methods and attributes are accessed by writing the name of the object followed by the ________. a) method name/attribute name

b) method/attribute index c) dot operator d) property operator Ans: c) 13.4 String Object 13.4 What does the value string contain after the following code is executed? var string = "Good luck on the test"; string = string.charAt( 3 ); a) Goo b) 3 c) d d) Nothing, the string conversion generates an error. Ans: c) 13.5 What does the value string contain after the following code is executed? var string = "Good luck on the test"; string = string.split( " " ); a) Good luck on the test b) Good.luck.on.the.test c) Good,luck,on,the,test d) Nothing, the string conversion will generate an error. Ans: a) 13.6 What does the value string contain after the following code is executed? var string = "Good luck on the test"; string = string.link("www.deitel.com") a) a link to www.deitel.com with the text "www.deitel.com" b) a link to www.deitel.com with the text "Good luck on the test" c) the text "www.deitel.com" d) Nothing, the string conversion will generate an error. Ans: b) 13.7 What is the value of s3 after the following code is executed? var s1 = one, s2 = two, s3 = three; s1.concat(s2) s3 = s1; a) one b) onetwo c) three d) onetwothree Ans: b) 13.8 What is the value of s1 after the following code is executed? var s1 = "deitel and associates" s1 = s1.slice( 6 ) a) deitel b) deitel and asso c) and associates

d) deitel and associates Ans: c) 13.9 Which of the following methods would you use to search a character for a specific string? a) substring b) charAt c) substr d) indexOf Ans: d) 13.10 Which of the following methods would you use to convert a list of Unicode values into a string containing the corresponding characters? a) charAt b) charCodeAt c) fromCharCode d) UCodeToChar 13.5 Date Object 13.11 What will value contain after the following code is executed? var value = new Date(); value = value.valueOf(); a) the current date in the format hh:mm:ss calculated from the number of milliseconds between midnight January 1, 1970 and the current date b) a large integer representing the number of milliseconds between midnight January 1, 1970 and the current date c) the current date in the format hh:mm calculated from the number of milliseconds between midnight January 1, 1970 and the current date d) a large floating point number representing the number of milliseconds between midnight January 1, 1970 and the current date Ans: b) 13.6 Boolean and Number Objects 13.12 Which of the following methods does the JavaScript Boolean object not possess? a) toString b) valueOf c) toInt d) The JavaScript Boolean object does not possess publicly accessible methods. Ans: c) 13.13 Which of the following methods does the JavaScript Number object not possess? a) toString b) toFloat c) valueOf d) MAX_VALUE Ans: c)

13.6 Boolean and Number Objects 13.12 Which of the following methods does the JavaScript Boolean object not possess? a) toString b) valueOf c) toInt d) The JavaScript Boolean object does not possess publicly accessible methods. Ans: c) 13.13 Which of the following methods does the JavaScript Number object not possess? a) toString b) toFloat c) valueOf d) MAX_VALUE Ans: c)

Вам также может понравиться