csc 222

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is the ending value of numItems if myChar = 'X'? switch (myChar) { case 'W': numItems = 1; case 'X': numItems = 2; case 'Y': numItems = 3; case 'Z': numItems = 4; } 9 2 3 4

4

101100

6

C, C++, and Java are what kind of language? Compiled Interpreted

a

Consider the problem of determining the longest word in a list of words with various lengths. What is the problem input / output? Array of all words / String value for the longest word Integer value for the number of words / String value for the longest word String value for the longest word / Integer value for the number of words String value for the longest word / Array of all words

a

Given two integer arrays prevValues and newValues. Which code copies the array prevValues into newValues? The size of both arrays is NUM_ELEMENTS. for (i = 0; i < NUM_ELEMENTS; ++i) { newValues[i] = prevValues[i]; } newValues = prevValues; newValues[NUM_ELEMENTS] = prevValues[NUM_ELEMENTS]; newValues[] = prevValues[];

a

The world population is over 7 billion. Which declaration uses the fewest bits while guaranteeing that worldPopulation can be assigned the value 7 billion without error? long worldPopulation; int worldPopulation; short worldPopulation; byte worldPopulation;

a

What class has methods to extract strings, integers, and other types from an InputStream? Scanner System.in IOException

a

What is y after executing the statements? x = 5; y = x + 1; y = y * 2; 12 5 8 6

a

What will a compiler do for the following code? /* numItems = 2; /* Total items to buy */ rate = 0.5; */ Generate an error. Ignore both statements. Generate code for numItems = 2, but ignore rate = 0.5. Ignore numItems = 2, but generate code for rate = 0.5.

a

Which algorithm steps correctly solve the problem: How many occurrences of 2 exist in the array? (1) loop through array (2) inspect each array element (3) increment counter if 2 is found (1) loop through array (2) increment counter if 2 is found (3) inspect each array element (1) inspect each array element (2) loop through array (3) increment counter if 2 is found (1) increment counter if 2 is found (2) loop through array (3) inspect each array element

a

Which kind of language is first converted to an executable, then run? Compiled Interpreted

a

Which kind of language usually has faster execution? Compiled Interpreted

a

Which statement extracts the next String before whitespace in inputLine? inSS.next(); inSS.nextInt(); inSS.nextLine();

a

________ is the physical aspect of the computer that can be seen. Hardware Application program Operating system Software

a

For the given pseudocode, which XXX and YYY will output the number of times that 10 is input (stopping when 0 is input)? Choices are in the form XXX / YYY. count = 0 val = Get next input While val is not 0 If val == 10 XXX Else YYY val = Get next input Put count to output count = count + 1 / count = 0 count = count + 1 / (nothing) count = count + val / (nothing) count = count + val / count = 0

b

How many spaces will the compiler ignore in the code below? numToBuy = numNeeded - numInStock + 2; 3 6 7

b

If the input is 7, what is the output? If x less than 10 Put "Tiny " to output Else Put "Not tiny " to output If x less than 100 Put "Small " to output Tiny Tiny Small (No output) Not tiny Small

b

One byte has ________ bits. 16 8 12 4

b

Python, Javascript, and MATLAB are each what kind of language? Compiled Interpreted

b

Suppose Jean's keyboard is not working, so they hypothesize that the keyboard cable is disconnected. Jean checks if the cable is plugged into the keyboard, and the cable is. What is the result of this test? The test result validates the hypothesis The test result is inconclusive The test result invalidates the hypothesis The test result is not useful

b

Suppose the lights in Suzy's room suddenly go out, so she walks into another room and turns on the lights. Which part of troubleshooting does "turns on the lights" represent? Hypothesis Test Solution Problem

b

What is passed to the Scanner's constructor to initialize a Scanner object? System.in An InputStream nextInt()

b

What is the output? public static void main(String[] args) { for (int i = 0; i < 3; ++i) { System.out.print(i); } System.out.print(i); } 012 Error: The variable i is not declared in the right scope 0123 0122

b

Which is the best stub for a method that calculates an item's tax? public static double ComputeTax(double itemPrice) { double tax; return tax; } public static double ComputeTax(double itemPrice) { System.out.println("FIXME: Calculate tax"); return 0.0; } public static double ComputeTax(double itemPrice) { double tax = 0.0; } public static double ComputeTax(double itemPrice) { double TAXRATE = 0.0675; return itemPrice * TAXRATE; }

b

Which kind of language can be run right away, without converting to an executable first? Compiled Interpreted

b

Which kind of language is more portable to different machines? Compiled Interpreted

b

Which language has extensive support for objects? c c++

b

Which programming language is compiled and statically typed, but not object-oriented? Python C Java C++

b

Which regular loop corresponds to this enhanced for loop? char[] vowels = {'a', 'e', 'i', 'o', 'u'}; for (char item: vowels) { System.out.println(item); } for (int i = 0; i < item.length; ++i) { System.out.println(vowels[i]); } for (int i = 0; i < vowels.length; ++i) { System.out.println(vowels[i]); } for (int i = 0; i < item; ++i) { System.out.println(vowels[i]); } for (int i = 0; i < vowels.length; ++i) { System.out.println(item[i]); }

b

Which statement initializes the Scanner object inSS to create an input string stream using the String variable inputLine? Scanner inputLine = new Scanner(inSS); Scanner inSS = new Scanner(inputLine); Scanner inSS = inputLine;

b

0 or 1

bit

8 bits

byte

An input string stream is used to read data from _____. standard input a keyboard a string

c

Choose an appropriate first hypothesis for the following situation: An external webcam connected to a computer suddenly stops working Move the webcam Update the webcam's software The webcam is unplugged Plug in the webcam

c

Computer can execute the code in ________. assembly language none of the above machine language high-level language

c

How many lines will the compiler ignore in the code below? int userAge; int currentDecade; int nextDecade; int nextMilestone; // FIXME: Get user age userAge = 29; // Testing with 29 currentDecade = userAge / 10; nextDecade = currentDecade + 1; nextMilestone = nextDecade * 10; 1 2 3

c

In the branching programming structure ________________. evey line of code is executed exactly once. a selection statement is used to count the number of time to execute a line or block of code. a selection statement is used to determine the next line or block of code to execute. several selection statements are needed to determine the next statement to execute.

c

Suppose Maya is playing an online game with friends when suddenly she is disconnected from her party. She suspects her internet disconnected, but her network settings show a good ethernet connection with no issues. What is an appropriate next step? Switch her connection from ethernet to WiFi Stop playing the game for the rest of the day Ask her friends if anyone else disconnected Reinstall the game on her computer

c

What are the names of the basic programming structures? loops, selection, repetition lists, arrays, variables, code sequential, branching, looping classes, and objects

c

What is the ending value of sum, if the input is 2 5 7 3? All variables are integers. x = scnr.nextInt(); sum = 0; for (i = 0; i < x; ++i) { currValue = scnr.nextInt(); sum += currValue; } 5 15 12 10

c

What will a compiler do for the following three lines of code? // x = 2; // width // y = 0.5 // z = x * y; Total area Yield an error for line 3 (z = ...) Yield an error for line 2 (y = ...) Ignore all three lines Yield an error for line 1 (x = ...)

c

Which is an example of a process? 15 int x + y y, 10

c

Which statement correctly calls calcArea() with two int arguments? public void calcArea(int w, int h); calcArea( ); calcArea(4, 12); calcArea(int w, int h);

c

Which tool parses source code to generate HTML documentation? Doc comment Compiler Javadoc Block tag

c

A character variable's value is stored in memory as _____ . a string a graphical symbol a floating-point value an integer value

d

Given: public static void printName(String first, String last){ System.out.println(last + ", " + first); } What is printed with the following method call? printName("Bob", "Henderson"); Bob, Henderson Henderson,Bob Bob Henderson Henderson, Bob

d

If the input is 5, what is the output? int x; int z = 0; x = scnr.nextInt(); if (x > 9) z = 3; z = z + 1; System.out.print(z); 4 0 3 1

d

In an instruction like: z = x + y, the symbols x, y, and z are examples of _____. instructions output visibles variables

d

Suppose Matt tries to login to his email, and the system reports "incorrect password". Order the following hypotheses and tests according to likeliness and ease-of-testing. 1. Hypothesis: Forgotten password, Test: Reset password 2. Hypothesis: System down, Test: Contact system support 3. Hypothesis: Mistyped password, Test: Retype password 1, 2, 3 2, 3, 1 1, 3, 2 3, 1, 2

d

What is the ending value of z? int x = 5; int y = 12; double z; z = (double)(y / x); 0.0 3.0 2.4 2.0

d

Which XXX and YYY correctly output the smallest values? Array userVals contains 100 elements that are integers (which may be positive or negative). Choices are in the form XXX / YYY. // Determine smallest (min) value int minVal; XXX for (i = 0; i < 100; ++i) { if (YYY) { minVal = userVals[i]; } } System.out.println("Min: " + minVal); minVal = 0; / userVal < minVal minVal = userVals[0]; / userVals[i] > minVal minVal = 0; / userVal > minVal minVal = userVals[0]; / userVals[i] < minVal

d

Which assigns the array's first element with 99? int[] myVector = new int[4]; myVector[1] = 99; myVector[] = 99; myVector[-1] = 99; myVector[0] = 99;

d

Which for loop will iterate 100 times? for (i = 0; i < 99; i++) for (i = 1; i < 99; i++) for (i = 1; i < 100; i++) for (i = 0; i < 100; i++)

d

________ translates high-level language program into machine language program. The operating system An assembler CPU A compiler

d

System.out.print("Dogs: " numDogs); Error No error

error

System.out.print("Hello friends!); Error No error

error

System.out.print(NumDogs); Error No error

error

System.out.print(numDogs). Error No error

error

System.print(numDogs); Error No error

error

int numCats numCats = 3; System.out.print(numCats); Error No error

error

system.out.print("Everyone wins."); Error No error

error

A compiler warning by default will prevent a program from being created. True False

false

A large program will be written for data analysis. Given a file of data, a user can apply different operations, like compute mean, compute median, compute max, etc. An object-oriented language is likely preferred. True False

false

If a compiler generates a specific message like "missing semicolon", then a semicolon must be missing somewhere, though maybe from an earlier line. True False

false

If a compiler says that an error exists on line 90, the actual error may be on line 91, 92, etc. True False

false

Spaces are always ignored by the compiler. true false

false

When a compiler says that an error exists on line 5, that line must have an error. True False

false

For the string "Orange", what character is at index 3? n a g r

n

System.out.print("Amy // Michael"); Error No error

no error

scientific notation

review

A large program will be written for a school system. A school has people, who have names, ages, etc. Some people have report cards, which has courses, grades, teachers, etc. A course has students, a teacher, a room, etc. An object-oriented language is likely preferred. True False

true

In a posttest loop structure, the block of code to be repeated is executed at least once. True False

true


Kaugnay na mga set ng pag-aaral

Math- Multiplication and Division

View Set

Chapter 2: Evaluating Nutrition Information

View Set

chapter 68 High-Risk Pregnancy and Childbirth

View Set

Anatomy and Physiology: Chapter 29 Development and Inheritance

View Set

CS4220: Computer Networks - Quiz 9 IP Addressing

View Set

Chapter 7: Legal Dimensions of Nursing Practice

View Set

6.1 Objects and Classes & 6.2 Writing a Simple Class, Step by Step

View Set

Exceptions to the Warrant Requirement

View Set

Creating and Solving Equations: Tutorial

View Set