Java Computer Science I

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

logical operators

&&, ||, and ! are ___________.

Relational operators

< , > , == are ________.

void

A ______ method is one that simply performs a task and then terminates.

sentinel value

A ______________ can be used to notify the program to stop acquiring input.

a) braces

A block of code is enclosed in a set of: a)braces b) parentheses c) double quotes d) brackets

Braces

A group of statements, suchs as the contents of a class or a method, are enclosed in ______.

counter controlled loop

A loop that repeats a specific number of times is known as an:

IOException

All methods that use a Scanner object to open a file must throw or handle _____________

the closest previous if clause that doesn't already have its own else clause

An else clause always goes with _____________.

.class

Byte code files end with the ____________ file extension.

8

Bytes consist of how many bits?

• Disk drive • External drive • CD drive • Solid state drive • USB drive • DVD drive

Common Secondary Storage devices:

A is less than B

How does character 'A' compare to the character 'B'?

floating point

Data types that allow fractional values are called ______________ numbers.

address

Each byte in memory is assigned a unique number known as a

semicolon

Every complete statement ends with a _______

**UNDERFLOW**

Examine the following code and determine the output that is produced int x = -1 if (x == 1) { System.out.println("**BELOW THRESHOLD**"); } else if(x == -1) { system.out.println("**UNDERFLOW**"); } else { system.out.println("**INTERMEDIATE STATE**") }

if count is equal to four, then only the block attached to the if is executed

Examine the following code and select the answer that best describes what the code accomplishes if(count == 4) { System.out.println("**CONVERYER FULL ***"); } else { count +=1; }

a) if appleDamaged is true, then the damaged message is printed to the console

Examine the following code. Select the answer that most accurately articulates what the code accomplishes: if(appleDamaged) { System.out.println("This particular apple is" + "damaged"); } a) if appleDamaged is true, then the damaged message is printed to the console b) if appleDamaged is false, then the damaged message is printed to the console c) this code contains syntax errors d) appleDamaged is being used as a counter, not as a boolean flag

- classes - variables -methods

Identifiers are programmer-defined names for:

throws, throws

If a method calls another method that has a ___________ clause in its header, then the calling method should have the same ___________ clause.

float (single precision) and double (double precision)

In Java there are two data types that can represent floating-point numbers called?

Passed by value

In Java, all arguments of the primitive data types are __________________, which means that only a copy of an argument's value is passed into a parameter variable.

Application- stand alone, runs without a browser. User runs the program locally, low security. Applet- Small applications that require the use of a Java enabled web browser to run. Enhanced security model since the user merely goes to a web page and the applet runs itself.

Java can be of two types, what are they and what do they do?

•public •class •static •void

Key words in the sample program are:

infinite loops. -A whileloop executes 0 or more times. If the condition is false, the loop will not execute.

Loops that do not end are called ___________

- public—method is publicly available to code outside the class - static—method belongs to a class, not a specific object.

Method modifiers are.....

machine code

Most compilers translate source code into executable files containing ____________________.

methods

Procedures in an object are known as _____________

syntax

Programming languages have strict rules known as what?

random-access memory and contains currently running programs and data used by those programs. divided into units called bytes

RAM is and contains what?

nextDouble()

Returns the next random number as a double. The number will be within the range of 0.0 and 1.0.

nextFloat()

Returns the next random number as a float. The number will be within the range of 0.0 and 1.0.

nextInt()

Returns the next random number as an int. The number will be within the range of an int, which is -2,147,483,648 to +2,147,483,648.

Random

Some applications, such as games and simulations, require the use of randomly generated numbers which use the _______ class

A) abstract data type

String is a class defined in the official Java Application Programming Interface (API). A String is distinguished the Primitive Data Types (PTD) because it is a(n) a)Abstract Data Type (ADT) b)binary operator c)unary operator

.- as a concatenation operator - as an addition operator

The + operator can be used in two ways...

hasNext()

The Scanner class's _______________ method will return true if another item can be read from the file.

for

The _______ loop is a pre-test loop.

while While the condition is true, the statements will execute repeatedly.

The _______ loop is a pretest loop, which means that it will test the value of the condition prior to executing the loop

break -The use of the breakstatement in loops bypasses the normal mechanisms and makes the code hard to read and maintain.

The ___________ statement can be used to abnormally terminate a loop.

do while

The _____________ loop is a post-test loop, which means it will execute the loop prior to testing the condition.

printerwriter

The _________________ class allows you to write data to a file using the printand println methods, as you have been using to display data on the screen.

Initialization section

The _____________________ of the forloop allows the loop to initialize its own control variable.

What does the class header do?

The class header tells the compiler things about the class such as what other classes can use it (public) and that it is a Java class (class), and the name of that class (Simple)

1

The combined assignment operators enable coupling a calculation with an assignment. For example: int i = o; i += 1; What is the value of i after this chuck of code executes?"

three

The conditional operator takes this many operands.

- Post-test loop - Use it where you want the statements to execute at least one time.

The do-whileloop:

D) %=

The following are examples of relation operators, except: A) != B) == C) >= D) %=

literals

The following data 72 'A' "Hello World" 2.8 are all examples of _________.

- Pretest loop - Use it where there is some type of counting variable that can be evaluated.

The forloop:

decision structure

The if statement is an example of a_____________

final

The key word is used to declare a named constant.

CPU, main memory, secondary storage devices, input and output devices.

The major hardware components of a computer are:

unary

The negation operator is _______.

arithmetic operators

The operators are called binary operators because they must have two operands.

functional decomposition

The process of breaking a problem down into smaller pieces is called ___________________

- Pretest loop - Use it where you do not want the statements to execute if the condition is false in the beginning.

The whileloop:

/**

These characters mark the beginning of a documentation comment.

/*

These characters mark the beginning of a multiline comment.

//

These characters mark the beginning of a single-line comment.

the equals method

This determines whether two different String objects contain the same string.

flag

This is a boolean variable that signals when some condition exists in the program.

null statement

This is an empty statement that does nothing.

nested if statement

This is an if statement that appears inside another if statement

nextInt(int n)

This method accepts an integer argument, n. It returns a random number as an int. The number will be within the range of 0 to n

default

This section of a switch statement is branched to if none of the case expressions match the switch expression

boolean expression

This type of expression has a value of either true or false

cast

This type of operator lets you manually convert a value, even if it means that narrowing conversion will take place.

braces

To create a block of statements, you enclose the statement in these.

import java.io.*;

To use the PrintWriter class, put the following importstatement at the top of the source file:

arguments

Values that are sent into a method are called _________

• Arrays allow us to create a collection of like values that are indexed. • An array can store any type of data but only one type of data at a time. • An array is a list of data elements.

What are arrays?

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

What are the relational operators?

println appends a newline and print appends nothing

What is the distinction between the print and println methods?

//

What starts a single line comment?

120

What will be the value of ans after the following code has been executed? int ans = 10; int x = 65; int y = 55; if (x >= y) ans = x+y;

B(15

What will be the value of x after the What will be the value of x after the following code is executed? int x = 75; int y = 60 if (x > y) x=following code is executed? int x = 75; int y = 60 if (x > y) x=x-y a) 75 b)15 c)60 d)135

20

What will e the value of ans after the following code has been executed? int x = 90, y = 55, ans = 10; if (x != y) ans *= 2;

Widening conversions

When Java converts a lower-ranked value to a higher-ranked type, it is called an ________.

&&

When determining whether a number is inside a range, it's best to use this operator.

b and c

Which of the following are not valid assignment statements? a) total = 9; b) 72 = amount; c) profit = 129 d) letter = 'W';

a, c and d

Which of the following are not valid println statements? A) system.out.println + "Hello World"; b) system.out.println ("Have a nice day"); c) out.System.println (value); d) println.out(Programming is great fun);

C) String

Which of the following variables is not a Primitive Data Type (PDT)? a) int b) long c) String d) double

nextDouble

Which scanner class method would you use to read a double as input?

nextLine

Which scanner class method would you use to read a sting as input?

Updating the control variable in the forloop body leads to hard to maintain code and difficult debugging.

Why should you avoid updating the control variable for the for loop?

JOptionPane

You can use this class to display dialog boxes

System.out.printf

You can use this method to display formatted output in a console window.

Causes a double quotation mark to be printed

\" double quote

Causes a single quotation mark to be printed

\' single quote

Causes a backslash to be printed

\\ backslash

Causes the cursor to back up, or move left, one position

\b backspace

Advances the cursor to the next line for subsequent printin

\n newline

Causes the cursor to go to the beginning of the current line, not the next line

\r carriage return

Causes the cursor to skip over to the next tab stop

\t tab

if

_____ statements decides whether a section of code executes or not

Methods

__________ are commonly used to break a problem down into small manageable pieces. This is called divide and conquer.

input validation

_______________ is the process of ensuring that user input is valid

primitive variables

____________________ are designed to hold only one value at a time.

else if

_____________statement adds the ability to conditionally execute code when the if condition is false.

syntax

_________errors are mistakes that the programmer has made that violate the rules of the programming language.

*/

documentation comments end with..

/**

documentation comments start with

A) this is an infinite loop

int x = 10, y = 20 while (y < 100) { x+= y; } a) this is an infinite loop b) 90 c)110 d) 120

infinite loop

int x = 10, y = 20; while (y < 100) { x+=y; }

b) 100

int x = 10; while (x < 100) { x += 10; } a)90 b)100 c)110 d)this code contains a syntax error

and && or || not !

what are the three logical operators?

true and false

what are the two variables for a boolean data type?

equal sign

what is the assignment operator?

software

what is the programs that run on a computer?

-byte -short -int -long -float -double -boolean -char

• Primitive data types are built into the Java language and are not derived from classes. • There are 8 Java primitive data types.


Ensembles d'études connexes

Mastering Biology CH 14 homework

View Set

Test and Measures Exam 1 (Chapters 1, 2, 3, 4, 5)

View Set

Chapter 1 Threats, Attacks, & Vulnerabilities

View Set

biology ch. 5homeostasis and transport

View Set

Operational Security (OPSEC) (JKO Post Test)

View Set

ZVP - Diagnóza, infekce, toxikologická onemocnění

View Set