CSE

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

Select the correct declaration for 2D array of 5 rows and 10 columns: A) CREATE myArray[5,10] OR CREATE myArray[5][10] B) CREATE myArray[10,5] OR CREATE myArray[10][5] C) CREATE myArray(5,10) OR CREATE myArray(5)(10)

A) CREATE myArray[5,10] OR CREATE myArray[5][10]

Consider two variables x and y. If the values of x =5 and y=10 if (x < 0) { System.out.println(" Mr. Spock"); } else { if (x > y) { System.out.println( "Captain Kirk"); } else { System.out.println( "Star Trek it is!!!"); } } What is displayed as the result of the code being executed: A) Star Trek it is!!! B) Captain Kirk C) Mr. Spock D) Nothing will be printed/displayed

A) Star Trek it is!!!

Imagine a game of Yahtzee where a roll of dice always returns an even number. Consider the snippet of code where the number is variable that stores the value of the dice. What will the code display? int result = number % 2; if (result == 0) System.out.println("TRUE"); else System.out.println("FALSE"); A) TRUE B) Unable to determine C) Neither condition is satisfied D) FALSE

A) TRUE

Pseudocode is A) an informal high-level description of the operating principle of a computer program or algorithm. B) a machine. C) a formal programming language.

A) an informal high-level description of the operating principle of a computer program or algorithm.

What would be the best datatype to represent product? A variable that stores information about the number of items currently in stock in a grocery store. A) int B) float C) String D) double

A) int

A distinguishing feature of methods that have the reserved word void in the method header is that they have A) no return statements. B) a single return statement. C) none of the other answers D) multiple return statements.

A) no return statements.

Consider the expression: value >= 30 Which of the following is equivalent to this expression: A) value > 30 OR value == 30 B) NOT(value > 31) C) NOT(value < 29) D) value > 30 AND value == 30

A) value > 30 OR value == 30

What is the value of j after this code is executed? int i = 6, int j=10; j+=i; A) 10 B) 16 C) 6 D) 4

B) 16

Consider an array values. The array is of size 7. The statement: System.out.println(values[7]);//Java Console.WriteLine(values[7]);//C# cout << values[7] << endl;//C++ will A) produce a syntax error. B) produce an index out of bounds error. C) output 0. D) output 7.

B) produce an index out of bounds error.

What is the output of the following code? int num1 = 500; int num2 = 200; int num3 = 300; double average = num1 + num2 + num3 / 3; PRINTLINE(average); A) 333.0 B) Error message C) 800.0 D) 333.33333333333

C) 800.0

IDE stands for A) Intramural Department Executive B) Initial Degree Expectations C) Integrated Development Environment

C) Integrated Development Environment

Programming starts with A) writing code until it works. B) looking online for the answers. C) developing an algorithm.

C) developing an algorithm.

The Boolean expression ((A AND B) AND (NOT(A AND B)) evaluates to: A) true whenever only A is true or only B is true. B) true whenever both A is true and B is true. C) false in all cases. D) true in all cases.

C) false in all cases.

Which of the following correctly refers to the last element in the array of integers called numbers? A) numbers[length of numbers] B) numbers[last numbers] C) numbers[length of numbers-1] D) numbers[size]

C) numbers[length of numbers-1]

Program design consists of A) the ability to solve problems. B) writing the documentation for a program. C) steps a programmer should do before they start coding a program in a specific language. D) writing the code for a program.

C) steps a programmer should do before they start coding a program in a specific language.

An object's method is called by A) using the object name only. B) using the class name, followed by a period and the method name. C) using the object's name, followed by a period and the method name. D) using the method name only.

C) using the object's name, followed by a period and the method name.

An object is a primitive data type. True or False

False

If x = 3, y = 1, and z = 5 then the following Boolean expression evaluates to true: ( x > 0) && (y == 0) || (z < 5) True or False

False

In programming && is considered an arithmetic operator. True or False

False

Input is sending messages to the console/user. True or False

False

Methods can return only primitive data types. True or False

False

Output is process of reading information from user, usually via keyboard or mouse. True or False

False

Pseudocode form of writing should be used only when the logic of the program is complex.

False

Strings are a primitive data type which support the '+' operation. True or False

False

The statement int[] list = {5, 10, 15, 20}; (C# & Java) int list[] = {5,10,15,20}; (C++) gives an error since there is no new reserved word included in the statement. True or False

False

You can only nest FOR loops. True or False

False

Which of these sorts was not covered in the lecture slides? A Insertion B Selection C Bubble D Merge

Merge

2D Arrays are still homogeneous. True or False

True

2D arrays are declared in row, column order for C++, C# and Java. Meaning first value is number of rows, second value is number of columns. True or False

True

A flowchart is a type of diagram that represents an algorithm, workflow or process. True or False

True

A relational operator used when comparing primitive data types is !=. True or False

True

A switch statement is similar to an if statement in that both are used to alter the flow of a program. True or False

True

An array index cannot be of the double, float or String data types. True or False

True

An array must be sorted for a Binary search to work properly. True or False

True

An if statement does not need to have an else clause. True or False

True

Formal parameters in method headers require including the data type for each parameter in source code. True or False

True

If the expression xyz % 3 == 0 is true and xyz is a positive integer, then the value stored in the variable xyz is evenly divisible by 3. True or False

True

If the variable isTested is a Boolean, then the statement below is a valid control expression (in all three languages): if (isTested) True or False

True

In general, the advantage of using a binary search over a linear search increases when searching larger sorted arrays. True or False

True

Is this valid syntax for a FOR loop? for(int j = 0; j < 1000; j++) PRINT(J); True or False

True

Once an array is created, it cannot be resized during program execution. True or False

True

Software testing involves the execution of a software component or system component to evaluate one or more properties of interest. True or False

True

Strings are immutable which means once a String object is created its contents cannot be changed. True or False

True

The MAIN method tells the program where to begin running code as it is the entry or starting point for the program. True or False

True

The body of a method can be empty. True or False

True

new is the reserved word used to create an object. True or False

True

All method (function) headers must include parameters. True or False

False

All methods must have a return statement. True or False

False

A String (or string) object is a primitive data type. True or False

False

What is the output of the following code? int u = 3; int v = 5; u += v; v += u; u -= v; v -= u; PRINT (u + ", " + v); A) 5, 3 B) 3, 5 C) -5,-3 D) -5, 18

D) -5, 18

Consider the snippet of code: What will this code print? int y=1; int x=1; PRINTLINE(x++); A) 2 B) 0 C) unknown D) 1

D) 1

The parameters in the method call (actual parameters) and the method header (formal parameters) must be the same in A) sequence B) data type. C) quantity. D) All of the other choices

D) All of the other choices

FOREACH loops cannot be used for which of the the following tasks? A)_ Printing B) Searching C) Summing D) Assignment

D) Assignment

Which of the following programming terms is enforced by declaring class attributes as private? A) Escape Sequences B) None of these answers C) Encapsulation D) Escalation

D) Encapsulation

Consider the array declaration and instantiation: int[ ] arrayOne = new int[5]; Which of the following is true about arrayOne? A) It stores 5 elements with legal indices from 1 to 5. B) It stores 6 elements with legal indices from 0 to 5. C) It stores 4 elements with legal indices from 1 to 4. D) It stores 5 elements with legal indices from 0 to 4.

D) It stores 5 elements with legal indices from 0 to 4.

Consider variable x which is an int where x = 0, which statement below will be true after the following loop terminates? while (x < 100) { x *= 2; } A) x == 0 B) x == 2 C) x == 98 D) The loop won't terminate. It's an infinite loop.

D) The loop won't terminate. It's an infinite loop.

Object Oriented Programming is categorized by use of: A) Graphical User Interfaces. B) modules to combine program statements C) used for a common purpose. the goto statement D) classes and objects

D) classes and objects.

When a variable is declared within a method and its scope is within the method it is known as a(n) A) public instance data. B) global variable. C) actual parameter. D) local variable.

D) local variable.

Debugging is the process of A) publishing the source code to the client. B) compiling the source code. C) writing source code. D) solving errors in the source code.

D) solving errors in the source code.


Kaugnay na mga set ng pag-aaral

The Profession of Nursing - NUR 114

View Set

BIO 121: Chapter 2 - Healthy Diets

View Set

Accounting chapter 8 wiley questions

View Set

Marketing CH. 17, Mktg chapter 17, 18, 19, 20,21, MKTG ch. 18, Marketing chapter 19, Marketing Chapter 18, Marketing Chapter 18, Marketing CH. 17, Marketing CH. 17, Marketing Chapter 18, Chapter 16, Intro to Bus. Chapter 13, Marketing 4, Chapter 16,...

View Set