CS 0007 - Introduction to Java - Exam 1

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

What is the not equal operator?

!=

What are the parts of format specifier syntax?

%[flags][width][.precision]conversion

What are the three logical operators?

&& - AND || - OR ! - NOT

The increment operator is?

++

What are the operators that add and subtract one from their operands?

++ and --

What are some examples of combined assignment operators?

+= -= *= /= %=

What should be added to the class header to throw an exception when using I/O?

...args) throws IOException

In Java, the beginning of a line comment is marked with?

//

What are the steps taken when a file is used by a program?

1. The file must be opened, a connection is created between the file and the program. 2. Data is then written to the file or read from the file. 3. When the program is finished using the file, the file must be closed.

A loop that is inside another loop is called?

A nested loop

Whats the difference between a void method and a value-returning method?

A void method simply executes a group of statements and then terminates, whereas a value-returning method returns a value to the statement that called it.

What kind of program is Java?

An object-oriented program

Values that are sent into a method are called?

Arguments

In the following code, double num = 5.4; System.out.println(num); num = 0.0; System.out.println(num) is an example of: A) A value-returning method B) A void method C) A complex method D) A local variable

B) A void method

This part of a method is a collection of statements that are performed when the method is executed.

Body

If you are using a block of statements, don't forget to enclose all of the statements in a set of _____.

Braces {}

What will be the value of x after the following code is executed? int x = 10; do { x *= 20; } while (x > 5); A) 10 B) 200 C) This is an infinite loop D) The loop will not be executed, the initial value of x > 5.

C) This is an infinite loop

Major Components of a Computer

CPU, Memory/RAM, I/O, Secondary Storage

Which of the following is NOT a primitive data type? A) short B) long C) float D) String

D) String

Secondary Storage

External Hard Drive, Disk Drive (CD)

What does JVM stand for?

Java Virtual Machine

A value that is written into the code of a program.

Literal

This is a control structure that causes a statement or group of statements to repeat.

Loop: while, do while, for

Encloses a group of statements, such as the contents of a class or method.

Opening and closes braces { }

Binary Operators

Operators that perform operations in one or more operands

Keyword

Reserved words

Variable

Symbolic names made up by the programmer that represents locations in the computer's RAM

Constants (declared final)

Symbolic names made up by the programmer whose values cannot be changed

The rules that must be followed when writing a program. It dictates how key words and operators may be used, and where punctuation symbols must appear.

Syntax

When you want to append data to a file, which class would you use?

The FileWriter class

Which class allows you to quickly display a dialog box?

The JOptionPane class

Which classes can you use to write data to a file?

The PrintWriter class, and the FileWriter class

Which class can be used to read input from the keyboard.

The Scanner class

Statement that causes a loop to terminate early.

The break statement

Statement that causes a loop to stop its current iteration and begin the next one.

The continue statement

This loop is ideal in situations where you always want the loop to iterate at least once.

The do-while loop

Which loop(s) is a posttest loop?

The do-while loop, and the for loop

This loop is ideal in situations where the exact number of iterations is known.

The for loop

Which loop would you use if you are performing a known number of iterations?

The for loop

Which decision structure causes one or more statements to execute only when a boolean expression is true?

The if Statement

Which decision structure will execute one group of statements if its boolean expression is true, or another group if its boolean expression is false.

The if-else Statement

Which statement lets the value of a variable or expression determine where the program will branch to.

The switch Statement

If the following Java statements are executed, what will be displayed? System.out.println("The top three winners are\n"); System.out.println("Jody, the Giant\n"); System.out.print("Buffy, the Barbarian"); System.out.print("Adelle, the Alligator");

The top three winners are Jody, the Giant Buffy the BarbarianAdelle, The Alligator

This loop is ideal in situations where you do not want the loop to iterate if the condition is false from the beginning. It is also ideal if you want to use a sentinel value to terminate the loop.

The while loop

Which loop can be used to create input routines that repeat until acceptable data is entered?

The while loop

Which loop(s) is a pretest loop?

The while loop

True or False? The Java Virtual Machine is a program that reads Java byte code instructions and executes them as they are read.

True

A named storage location in the computer's memory.

Variable

What are some examples of escape sequences?

\n - Newline \t - Horizontal Tab \b - Backspace \r - Return

A data type that allows you to create variables that may hold on of two possible values: true or false.

boolean

What are the six data types for numeric data?

byte short int long float double

A data type used to store characters.

char

Which keyword can be used in a variable declaration to make the variable a named constant?

final

The _____ statement is used to make simple decisions in Java

if/else

What must be imported before using I/O?

import java.io.*;

What must you import before using the JOptionPane class?

import java.swing.JOptionPane;

What must you import before using the Scanner class?

import java.util.Scanner;

What are the commands to compile and run a file called ReadIt.java?

javac ReadIt.java java Readit

A _____ is a part of a program that repeats.

loop

In Java, _____ must be delared before they can be used.

variables

What will be displayed as a result of executing the following code? int x = 5, y = 20; x += 32; y /= 4; System.out.println("x = " + x + ",y = " +y);

x = 37, y = 5


Conjuntos de estudio relacionados

GST 222 - LECTURE 1 - CONCEPTUAL DEFINITIONS OF PEACE AND CONFLICT

View Set

AP Chemistry Chapter Three Review Questions

View Set

Chapter 46, Assessment of the Eye and Vision

View Set

IT 376 Exam 1 Review (HW1 & HW2)

View Set

biology class normal lecture exams

View Set