Computer programming final

Ace your homework & exams now with Quizwiz!

What is true about objects? Choose all that apply. a) They have both data and operations. b) Numbers are objects. c) They are units of codes. d) Strings are objects.

All of the above

What does this statement do? misc [3] = 8; a) Change the fourth item of the array to 8. b) Get the fourth item of the array and check if it is equal to 8. c) Get the third item of the array and check if it is equal to 8. d) Change the third item of the array to 8.

Change the fourth item of the array to 8

What is the value of S after these two statements? s= 'smart'; s= s.substring (0,3); a) smar b) sma c) sm d) mar

sma

Using the code in exercise 11.13 on page 211, what is the output message if x is 10 and y is 8? a) one b) two c) three d) no answer text provided

two

T/F: An array must have at least 1 item.

False

If words = 'Hello, welcome to N201!', what does words.split (',') do? a) It generates an array with three values. b) It generates an array with four values. c) It generates an array with two values. d) It generates an array with five values.

It generates an array with two values

What is true about a text area? Choose all that apply. a) It has a "rows" attribute to specify the height of the area. b) It is defined using type='textarea.' c) It cannot have an "id" attribute. d) It can contain any number of text lines.

It has a "rows" attribute to specify the height of the area. It can contain any number of text lines.

What is the behavior of this code? n = 3 while (n<10) { n = n-1; } alert(n); a) It will output 2. b) It will output 4. c) It will output 3. d) It results in an infinite loop.

It results in an infinite loop.

What is true about "toUpperCase" function with regards to string operations? Choose all that apply. A) It returns a value. B) It changes all the lower case letters of a string to upper case letters. C) It is a method D) It takes a string as a parameter.

It returns a value. It changes all the lower case letters of a string to upper case letters. It is a method.

Which of the following can correctly assign values to an array? Choose all that apply. a) fruits = [1, 2, 4.3, 9+5]; b) fruits = ['apple', 1, 'o', 'kiwi']; c) fruits = ['apple', 'orange', 'pear', 'kiwi']; d) fruits = ['a', 'o', 'p', 'k',]; e) fruits - ['apple', 'orange', 'pear', 'kiwi'];

all of them

Which of the following is a special kind of variable? a) a method of an object b) an object c) a property of an object

an object

_ signals can vary across an infinite range of values

analog

What is the value of roll1 after running the following statement? roll1 = RandomInt(1,6); a) any number between 1 and 6 b) 1 c) 6 d) no answer text provided

any number between 1 and 6

What is the output of the following code? s = 'Hello and welcome!'; alert(s.length); a) 18 b) 19 c) 20 d) 21

18

What is the output of num1? str= 'banana'; num1=str.search('n'); a) 1 b) 2 c) 3 d) 4

2

If s = 'computer', what is the return value of s.search('put')? a) 1 b) 3 c) 0 d) 2

3

If the array m is assigned this way. m = [2, 0, 1.1, 2.5]; What is the value of m.length? a) 4 b) 3 c) 1 d) 2

4

Which of the following can join strings together? a) == b) = c) + d) /

+

If s= 'computer', what is return value of s.search('n')? a) 1 b) 2 c) -1 d) 0

-1

What is the output of the following code: a= -2 b= 20; if (a> 0 || b>0) { alert(a); } a) -2 b) 20 c) no output

-2

What is the output of the following code? count = 0; while (count <=5) { count = count + 1; alert(count); } a) 0,1,2,3,4,5 b) 1,2,3,4,5 c) 1,2,3,4,5,6 d) 0,1,2,3,4,5,6

1, 2, 3, 4, 5, 6

What is the output of misc[0]? misc= [1.234, 'foo', 7-5, true, 3, 'foo']; a) 1.234 b) 7-5 c) true d) 3

1.234

What are the values in the array m after running the following statements? m = [1,2,3,4,5]; m[2] = 8; m[3] = m[4]*0; a) 1,2,8,4,5 b) 1,2,3,8,5 c) 1,8,0,4,5 d) 1,2,8,0,5

12805

_ signals utilize only a finite set of values

Digital

What is the behavior of this code? n = 8 while (n<10) { n = n + 1; } alert (n); a) It will output 8. b) It will output 10. c) There is no output. d) It results in an infinite loop.

It will output 10

Using the code in Figure 15.4 on page 278, what is the return value of the function if the function call is Capitalize('programming')? a) Program b) PROGRAMMING c) programming d) Programming

Programming

Which statement will decrease x by 1? a) x-1 b) x = x-1 c) x--1 d) x == x-1

x=x-1

T/F Parameters are variables that are declared and initialized automatically

True

Which of the following expresses "if x is 20 or 30"? a) if (x==20 || 30) b) if (x=20 || 30) c) if (x==20 || x==30) d) if (x==20) || if (x==30)

if (x==20 || x==30)

What is the output of the following code? count=0; while (count <0) { count = count + 1; alert(count); } a) 0 b) 1 c) no output d) no answer text provided

no output

Variables that correspond to the function's inputs (if any) a) parameters b) return variable c) local variables

parameters

What is the value of C after running the following statements? w = 'screen'; c= w.charAt(0); a) 0 b) s c) w d) screen

s

If the wage array is assigned this way: wages=[20, 41, 18, 2]; Which of the following is evaluated to 61? a) wages [1] + wages [2] + wages [3] b) wages [0] + wages[1] c) wages[0] + wages[1] + wages[2]

wages [1] + wages[2] +wages[3] wages [0] + wages[1]


Related study sets

MGT 340- Organizational Behavior Final Exam Review

View Set

Spanish 12 Chapter 9 Car Accident Vocabulary

View Set

Chapter 49: Immunologic Agents and Chapter 51: Immunomodulating Drugs

View Set

Prep U- Chapter 58: Assessment & Management of Patients With Breast Disorders

View Set

Prin. Bus. Fin. Modul 1 "Building A Balanced Budget" { Mr. Bayaborda }

View Set

System Analysis and Design: Project Management (CH4)

View Set