Programming Quiz 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

How many bytes are in a kilobyte?

1024 bytes

The Java source file name must match what?

the public class name in the program

What are logical operators used for?

to create a compound Boolean expression

What causes a logic error?

when a program does not perform the way it was intended to

What are the logical operators in java?

&& and both conjunction - only true when both are true || or either disjunction - only false when both are false ! not opposite negation - true if false and false if true ^ exclusive or different - TF or FT operate with Boolean values and variables

What is the assignment operator in java?

(=) equal sign

How many bytes are in a megabyte?

1 million bytes

How many bytes are in a terabyte?

1 trillion bytes or 1,000 gigabytes

What do runtime errors do?

Cause a program to terminate abnormally

What is a high level language?

English-like and easy to learn and program Ex. Java

What does java do when evaluating an expression with values of mixed data types?

Java automatically converts the operands to appropriate types

Does the complier read comments?

No - java comments are ignored by the complier

What are variables used for?

To store data in a program

Does is matter what case (upper/lower) is used in java programs?

Yes, java programs are case sensitive

What are methods contained in?

a class

What is a bit?

short for binary digit takes the value of 0 or 1

How do you explicitly convert a data type to another data type?

use the type(value) notation Ex: int age = (int)(18.1);// age is assigned the value 18

What are the java operators that perform numeric operations?

+ addition - subtraction * multiplication / division % remainder

Which operators are used to increase or decrease a variable by 1?

++ increment operator -- decrement operator

What are the augment assignment operators java provides?

+= addition assignment -= subtraction assignment *= multiplication assignment /= division assignment %=remainder assignment

What are the syntax rules for identifiers?

- must start with a letter or underscore -cannot start with a digit -cannot be a reserved word -can be any length

What are the 6 selection statements?

- one-way if statements - two-way if statements - nested if statements - multi-way if-else statements -switch statements -conditional expressions

How many bytes are in a gigabyte?

1 billion bytes

What are the relational operators?

== equal to != not equal to >, <, >=, <=

What is a two-way if-else statement?

IF it is true - execute statement for the true statement Otherwise (ELSE) - execute statement for the false statement

When is a one-way if statement used?

If you want to execute only when a certain statement is true

What is a multi-way if else statement?

The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed.

What is a switch statement?

The switch statement is a multiway branch statement. It provides an easy way to dispatch execution to different parts of code based on the value of the expression Matches what it needs to and executes or if its N/a it goes default. Like a call-center

A variable declared in a method must be assigned a value before it can be used. True or False?

True

What do relational operators yield?

a Boolean value

What is the Central Processing Unit (CPU)?

a computer's brain it retrieves instructions from memory and executes them

What is a block comment?

a java comment enclosed between /* and */

What is a line comment?

a java comment preceded by two slashes (//)

What does a java program need to run?

a main method

What does every statement in java end with?

a semicolon (;)

What is a byte?

a sequence of 8 bits

What is machine language?

a set of primitive instructions built into the computer

What do boolean data types store?

a true or false value

What is a computer?

an electronic device for storing and processing data includes both hardware and software

What causes a syntax/compile error?

an error in the syntax

What is a memory unit?

an ordered sequences of bytes

What do java source files end with before and after compiled?

before: .java extension after: creates a bytecode file - .class extension

How is a named constant declared?

by using the keyword "final"

What are the four integer data types java provides?

byte short int long

What is type narrowing?

casting a variable of a data type with a large range to a variable of a data type with a small range must be performed explicitly

What is type widening?

casting a variable of a data type with a small range to a variable of a data type with a larger range can be performed automatically w/o explicit casting

What is software?

computer programs - the invisible instructions/code for computers to perform

What are the two floating-point types java provides?

float double

What does memory do?

holds the program instructions and the program data for the CPU to execute

What is a nested-if statement?

if the if is inside another if statement nested if statement will only be executed if the one above it is true Ex: if (i>k){ if (j>k){ System.out.print("i & j are greater than k) } } else { System.out.print("i is less than or equal to k) }

Why is memory volatile?

information stored in memory is lost when the power is turned off

What does the keyword "break" do in a switch statement?

it is optional and keeps the next case statement from being automatically executed

What does the keyword "default" do in a switch statement?

it is used to execute statements when none of the case values match with the argument provided to the switch statement

Assembly language is what level of programming language?

low-level

What are identifiers?

names for naming elements such as variables, constants, methods, classes, and packages in a program

How are programs and data stored?

permanently on storage devices and moved to memory when the computer actually uses them

What are selection statements used for?

programming with alternative courses of action -- allow the program to test several conditions


Conjuntos de estudio relacionados

Chapter 4 multiple choice questions

View Set

Lesson 6 - The atlantic Slave Trade

View Set

Primerica Life Insurance State Exam RI

View Set

POLS 207 - Chapter 7 - Legislatures

View Set

Delegated, Concurrent, and Reserved Powers

View Set