CSC 15: Exam 1

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

Java Operators

+ addition - subtraction * multiplication / division % modulus (a.k.a. remainder)

Static Methods

- A block of Java statements that is given a name - A unit of procedural decomposition - A Java class usually contains multiple static methods in which solving some piece of the overall problem.

Class Constant

- A fixed value visible to the whole program. - Value can be set only at declaration; cannot be reassigned

Benefits of Static Methods

- Methods allow us to decompose a problem into smaller sub-problems that are easier to solve. - Using static methods makes the overall program more readable.- It helps to reveal the structure of the program. - The resulting code is also easier to understand and maintain - It helps to eliminate code redundancy

Scope of a Variable

- The part of a program where a variable exists. - From its declaration to the end of the { } braces - A variable declared in a for loop exists only in that loop. - A variable declared in a method exists only in that method.

Java's Data Type

- The type of the value that a variable can store. - The number of the bytes needed to store the value in the memory.

Escape Sequence Characters

- \t tab character - \n new line character - \" quotation mark character - \\ backslash character

Class Constant Examples

- public static final int DAYS_IN_WEEK = 7; - public static final double PI = 3.14; - public static final int SSN = 658234569;

print/println

- these two methods are used to display text output - they are members of the out object, which is a member of the System class

Comment

A note written in source code by the programmer to describe or clarify the code.

Java Expressions

A sentence with a minimum of two numbers and at least one math operation.

Declaring Variable

The part of the code that identifies the variable and the data type.

String Concatenation

The process of combining two strings with the + operator

Loop Control Variable

a variable that is changed by a constant value and determines the end of a loop

Decomposing a Problem

breaking a problem down into its component parts

Infinite Loops

for(int i = 1; i <= 10; i++) { for(int i = 1; i <= 5; i++) { System.out.println(Infinite Lines); } }

for loop

for(int i = 1; i <= 10; i++) { System.out.println(i); }

Use for loops to display for example odd number 1 3 5 7 9.

for(int odd = 1; odd <= 9; odd = odd + 2) { System.out.print(odd + " "); } System.out.println();

public static void <name> is called what?

method header

Hello.class

public class Hello { public static void main(String[] args) { System.out.println("Hello"); } }

A method can be called in a for loop:

public static void repeat() { for(int i = 1; i <= 3; i++) { numbers(); } } public static void numbers() { for(int i = 1; i<= 5; i++) { System.out.print(i + " "); } }

variable++; variable--;

variable = variable + 1; variable = variable - 1;

variable += value;

variable = variable + value;


Ensembles d'études connexes

Marine Science Chapter Four: Waves and Tides

View Set

everything about world history up until the protestant reformation

View Set

Effective Supervisory Practices 5th Ed. Chapters 8-16

View Set

La 50 preguntas y contestaciones de la tabla periódica

View Set

Prep U: Chapter 38- End of Life Care

View Set