CSE 1321 Test 2 Study Guide

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Program design consists of

A step a programmer should do before they start coding a program in a specific language

Array Index

A value that indicates the position in the array of a particular value. The last element in a zero-indexed array would be the length of the array, minus 1.

2D Array

An array of an arrays, characterized by rows and columns, arranged in a grid format, but still stored in contiguous, or side-by-side memory, accessed using two index values.

What is the value of the variable divisor in the following equation? int divisor = 3/6;

Answer = 0

BEGIN MAIN CREATE inputValue = 0, smallestValue = 0 DO PRINT "Please enter a positive integer (0 to quit): " READ inputValue IF (smallestValue == 0 AND inputValue > 0) smallestValue = inputValue ELSE IF (inputValue > 0) IF (inputValue < smallestValue) smallestValue = inputValue END IF ELSE IF (inputValue < 0) PRINT "Invalid entry, must be positive integers" END IF WHILE (inputValue != 0) END DO WHILE IF (smallestValue != 0) PRINT "Smallest value entered was: " + smallestValue ELSE PRINT "Have a good day." END IF END MAIN What is the Sentinel value for the loop? Question options: ~ q ~ Q ~ -1 ~ 0

Answer: 0

Evaluate: 3-6%5*2

Answer: 1

How many times will this PRINT statement execute with the following code? BEGIN MAIN FOR (CREATE int i=7; i<10; i++) PRINT"Hello there." END FOR END MAIN Question options: ~7 ~4 ~3 ~10

Answer: 3 (it will be less than 10 three times, 7,8,9)

Evaluate as an integer: 5*7+3%2-4

Answer: 32

Evaluate (18%5)-(6-4)+1

Answer: 8

Given variables x and y with assigned values, complete the code so that it prints the smallest value properly. Assume x and y are not equal. { System.out.println(x + " is the smallest value!"); } else{ System.out.println(y + " is the smallest value!"); }

Answer: if (x < y )

What do loops that have no terminating condition do?

Appear to lock up

Which group of operators is always evaluated first in an expression?

Arithmetic

FOREACH loops cannot be used for which of the the following tasks?

Assignment

Shortcut Operators

Assignment statements that are shortcuts to perform variable changes.

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

False

In an IF...ELSE IF...ELSE IF structure each statement whose expression evaluate to true will run their block of code

False

Only WHILE Loops can be nested:

False

(T/F) In the equation 2+8/4*2, the multiplication operation is evaluated first

False (left to right first)

(T/F) Keywords can be used as variables identifiers/names?

False (they are used to define the syntax and structure of the Python language)

Which variable could hold the literal numeric value 3.141 without losing any information

Float x

++

Increment by 1 operator

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 stores.

Int

IDE stands for

Integrated Development Environment

When a variable is declared within a method and its scope is within the method it is known as a(n)

Local Variable

Which group of operator is always evaluated last in an expression?

Logical

The time complexity for the bubble sort algorithm

O(n^2)

The time complexity for the selection sort algorithm

O(n^2)

||

OR operator

The symbols >, <, <=, >=, != and == are all _________ operators.

Relational

Which group of operators is always evaluated second in an expression?

Relational

This special input value is used to allow a user to end a loop

Sentinel

The parameters in the method call (actual parameters) and the method header (formal parameters) must be the same in

Sequence, data type, quantity

A______ contains 0 or more characters enclosed with double quotes

String Literal

Types of Complex Data

String, Classes, Arrays, Objects

(T/F) 2D arrays are declared in row, column order, meaning first value is number of rows, second value is number of columns

True

(T/F) 2D arrays are still homogeneous

True

(T/F) A flowchart is a type of diagram that represents an algorithm workflow or process

True

(T/F) A relational operator used when comparing primitive data type is !=

True

(T/F) A switch statement is similar to an IF statement in they both are used to alter the flow of a program

True

(T/F) A variable of datatype Char, can hold a single letter, number, or symbol

True

(T/F) An Array must be sorted for a Binary Search to work correctly

True

(T/F) An IF statement does not need to have an else clause

True

(T/F) An array can only hold variables of the same data type

True

(T/F) Assuming we have initialized an integer array of size 5, the following is a valid line of code: array[4] = 12;

True

(T/F) Debugging is the process of finding and correcting errors in your program's code

True

(T/F) Formal parameters in method headers require including the data type for each parameter in source code.

True

(T/F) If the variable is Tested is a Boolean, then the statement below is a valid control expression: IF(isTested)

True

(T/F) In an IF...Else IF...Else IF statement, the first conditional expression that evaluates to true is the only block o code that will run

True

(T/F) In general, the advantage of using a binary search over a linear search increases when searching larger sorted arrays

True

(T/F) In programming ! is considered a unary, logical operator

True

(T/F) In the equation 2+8/4*2,the division operation / is evaluated first

True

(T/F) Literals are values that are entered directly into code

True

(T/F) Logical operators are evaluated after comparison/relational operators

True

(T/F) Once an array is created it cannot be resized during program execution

True

(T/F) Software testing involves the execution o a software component or system component to evaluate one of more properties of interest

True

(T/F) Strings are immutable which means once a String object is created its contents cannot be changed.

True

(T/F) The MAIN method tells the program where to begin running code as it is the entry of starting point for the program

True

(T/F) The body of a method can be empty.

True

(T/F) The following line of code is valid and will compile: float variable = 1.23f;

True

(T/F) new is the reserved word used to create an object.

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

(T/F) An array index cannot be of the double, float, or string data type

True (Array index are always integer data type)

break

stops the loop

An object's method is called by

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

Consider the expression: value >= 30, Which of the following is equivalent to this expression?

value > 30 OR value == 30

Literals

values that are entered into the code

Constants

values that cannot change while the program is running

Logical OR

requires two operands

Common escape sequences

Escape sequence \r = crriage return \n newline \t tab \' single quote \" double quote \\ backslash

_____loop runs a pre-determined (known) number of iterations

FOR

(T/F) A Linear Search is always more efficient than a Binary Search

False

(T/F) A default case required as part of a switch statement

False

(T/F) All method (function) headers must include parameters.

False

(T/F) All methods must have a return statement.

False

(T/F) An IF statement must always have an ELSE statement after it:

False

(T/F) Assuming we have initialized on integer array of size 5, the following is a valid line of code: array[5]=12;

False

(T/F) Brute force is a good approach to programming.

False

(T/F) DO-WHILE loops are determinate loops

False

(T/F) FOR loops are indeterminate loops

False

(T/F) In programming ! is considered a binary, logical operator

False

(T/F) In programming && is considered an arithmetic operator:

False

(T/F) In the equation 2+8/4*2, the addition operation is evaluated first

False

(T/F) Input is sending message to the console/user

False

(T/F) Logical operators are evaluated before comparison/relation operators

False

(T/F) Methods can return only primitive data types.

False

(T/F) Only FOR loops can be nested:

False

(T/F) Output is process of reading information from user, usually via keyboard or mouse

False

(T/F) Pseudocode form of writing should be used only when the logic of program is complex

False

(T/F) Strings are a primitive data type which support the '+' operation.

False

(T/F) The following is an example of a valid program in Pseudocode: END MAIN

False

(T/F)Assuming we have initialized an integer array of size 5, the following is a valid line of code: array =12;

False

Continue

"skips" the current iteration

logical operators

&& [and] || [or] ! [not]

Arithmetic Operators

+, -, *, / , %

What is the value of the variable remainder in the following equation? long remainder = 3%6;

3

8 simple data types:

4 subsets of integers (byte, int, short, long) 2 subsets of floating point numbers (double & float) Character Boolean

Comparison Operators

<, >, <=, >=, ==, !=

1D Array

A linear collection of data items in a program, all of the same type, such as an array of integers or an array of strings, stored in contiguous memory, and easily accessed using a process called indexing.

&&

AND

A string is a primitive data types

False

Use all capital letters for____ and separate worse with an underscore

Constants

--

Decrement by 1 operator

What is the name of the case that executes if not other cases match for a SWITCH statement structure?

Default case

Which of the following programming terms is enforced by declaring class attributes as private?

Encapsulation

Printing an___________ prints a special character in an output string

Escape Sequence

A________ must be declared by specifying the variable's name and the type of information that it will hold

Variable

The____ and ____-_____ loops run un-determined (Unknown) number of iterations

WHILE and DO-WHILE

Spaces, blank lines, and tabs are called

White Spaces

Sentinel value

a value that when evaluated by the loop expression causes the loop to terminate

The parameters in the method call (actual parameters) and the method header (formal parameters) must be the same in

sequence, data type, & quantity

Object Oriented Programming is categorized by use of

classes and objects

complex data types

combinations of or extensions to primitive data types supported by PROGRAMMING LANGUAGES, OS and DBMS?

Correct format for a 2D array

create myArray [5,10] OR create myArray [5][10]

Pseucode

is an informal high-level description of the operating principle of computer program or algoritm

A distinguishing feature of methods that have the reserved word void in the method header is that they have

no return statement

!=

not equal to operator

Logical NOT

only works on one operand

Loops are

repetition statements that allow us to execute a statement (or block of statements) multiple times

Logical AND

requires two operands


संबंधित स्टडी सेट्स

Canadian Immigration and Refugee Law Chapter 5

View Set

Ultimate AP Gov Study Guide IWA Ch.1-3

View Set

Chapter 9 - Terms (Tom's): Chromosome Variation

View Set