ComSci Final

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/62

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

63 Terms

1
New cards

CPU

  • central processing unit

  • process a programs instructions

  • cam only process very simple instructions

2
New cards

Main Memory

  • working memory used to store current program, data the program is using, results of intermediate calulations

  • RAM (random access memory)

3
New cards

Auxiliary Memory

  • aka secondary memory

  • HHD, SSD, CD, DVD, Blu-Ray, USB

  • nonvolatile memory

4
New cards

Program

  • a finite sequence of instructions for a computer to follow written in a programming language

5
New cards

Operating System

  • OS

  • a supervisory program that oversees the operation of the computer

  • the main job of an OS is to manage process and hardware resources

    • eg retrieving and starting a program for you and manages resources like memory

6
New cards

Windows Commands

  • interact with the Windows OS via Command Prompt

  • Commons commands: dir, cd, cls, mkdir, tree, exit

7
New cards

Compile a Java File

javac MyProgram.java

8
New cards

Run a Java File

java MyProgram

9
New cards

Compiler

  • translates a program from a high level langauge to a low level language the computer can run

  • you enter source code into a compiler

  • compilers produce machine or assembly language programs called object programs

  • most high level languages need a different compiler for each type of computer and operating system

  • translates the entire source code into machine code before execution

10
New cards

Java Byte Code

  • the java compiler doesn’t translate a Java program into assembly language or machine language for a particular computer

  • instead, it translates a Java prpgram into byte-code

  • byte-code is the machine language for a hypothetical computer (or interpreter) called the Java Virtual Machine

  • a byte-code program is easy to translate into machine language for any particular computer

  • after compile a Java program into byte-code, tat byte-code can be used on any computer with a byte-code interpreter and without a need to recompile

11
New cards

Interpreter

  • translates source code into machine code line by line during runtime

12
New cards

Package

  • a library of classes that have been defined already

13
New cards

IDE

  • intregrated development environment

  • combines a text editor with commands for compiling and running Java programs

  • 3 features of eclipse: tells you where errors are, control f (find), convenient project management

14
New cards

Object-oriented programming (OOP)

  • our world consists of objects (people, trees, cars, etc)

  • objects can perform actions which affect themselves and other objects in the world

  • Object-oriented programming (OOP) treats a program as a colleciton of objects that intereact by means of actions

  • objects are called objects

  • actions are called methods

  • objects of the same kind have the same type and are objects of the same class

  • objects of the same class have a common set of methods and same the kinds of data but each object can have its own data values

  • classes reflect concepts, objects refelct instances that embody those concepts

15
New cards

Algorithm

  • finite sequence of instructions for solving a problem or performing some task

16
New cards

Types of Errors

  • syntax error

  • runtime error

  • logic error

17
New cards

Syntax Errors

  • grammatical mistakes in a program

  • ex. not ending a statement with a semicolon

18
New cards

Runtime Errors

  • errors that are detected when your program is running, but not during compilation

  • ex. attempting to divide by 0

19
New cards

Logic/Semantic Errors

  • errors that are not detected during compilation or while running, but which cause the program to produce incorrect results

20
New cards

Variables

  • stores data

  • value can be changed

    int styleChoice, numberOfChecks

    double balance, interestRate

    char jointOrIndividual

21
New cards

Data Types

  • Primitive Type

    • byte, short, int, long, float, double, char, boolean

  • Class/Object Type

    • String

22
New cards

Java Identifier

  • an identifer is a name, such as the name of variable

  • indentifiers may contain only: letters digits 0-9, the underscore character, the dollar sign symbol (we don’t use in the class)

  • first character cannot be a digit

  • can’t contain spaces, dots, astericks, or other characters

23
New cards

if-else statement

24
New cards

Tautology

  • a boolean expression is a tautology if and only if it is always true regardless of the values of its variables

25
New cards

Contradiction

  • a boolean expression is a contradiction if and only if it is always false regardless of the values of its variables

26
New cards

Contingency

  • a boolean expression that is neither a tautology nor a contradiction is called contingency

27
New cards

==

  • use for determining if two ints (or any primitive integer types), booleans, or chars have the same value

  • don’t use for floating points

  • don’t use for objects

28
New cards

compareTo()

  • returns 0 if both are equal

  • returns -1 if the first is lexigraphically greater than the second

  • returns 1 if the first is lexigraphically lesser than the second

29
New cards

Ternary Operator/Conditional Operator

  • useful with print and println statements

30
New cards

A program can be terminated normally by

System.exit(0);

31
New cards

Enumerations

  • consider a need to restrict contents of a variable to certain values

  • an enumeration lists the values a variable can have

32
New cards

The while Statement

knowt flashcard image
33
New cards

The do-while Statement

knowt flashcard image
34
New cards

The for Statement

knowt flashcard image
35
New cards

The for-each Statement

knowt flashcard image
36
New cards

Sentinel Value

  • for large input lists, a sentinel value can be used to signal the end of the list

  • ex. a negative number following a long list of nonnegative exam scores

37
New cards

The break Statement

  • can be used to end a loop immediately

  • the break statement end only the innermost loop or switch statement that contains the break statement

  • we will not be using break statements in loops in this class

38
New cards

The continue Statement

  • ends current loop iteration

  • begins the next one

  • we will not be using continue statements in loops in this class

39
New cards

Data Structures

  • a particular way of storing and organizing data in a computer so it can be used effectively

  • ex. array

40
New cards

Arrays

  • an array is a special kind of Java object

  • It is a collection of variables of the same type

  • fized size

    double[] temperature = new double [7];

41
New cards

new Operator

  • the new operator allocates memory for an object like an array on the program’s heap (as opposed the program’s stack)

42
New cards

Creating Arrays

type[] name;

name = new type[]{value1, value2, value3, …};

type[] name = {value1, value2, value3, …};

type[] name = new type[num];

43
New cards

Class definition

knowt flashcard image
44
New cards

Constructor

  • a constructor is a special method that intilizes objects of a class

  • it shares the same name as the class and lacks a return type

45
New cards

Instance Variable

a variable declared within class, but outside of any specific method or constructor

46
New cards

static

  • signifies that a variable or method is associated with the class itself, rather than with any specific instance

  • static variables are shared by all objects of a class

  • static variables are also called class variables

  • static varaibles belong to the class not to an individual object

  • a single copy shared by all instances of the class

47
New cards

final

ensures variables cannot be changed

methods cannot be overridden by subclasses

classes cannot be subclassed

48
New cards

The Keyword this

  • inside the class the unnamed object can be referred to with the name this

  • the keyword this stands for the current instance of the object

  • it can be used to call methods or access instance variables in this object

49
New cards

Information Hiding

  • programmer using a class method need not know details of implementation

  • designing a method so it can be used without knowing details

  • also refered to as abstraction

50
New cards

Pre- and Postcondition Comments

Precondition Comment:

  • states condtion that must be true before method is invoked

Postcondition Comment:

  • tells what will be true after method execution

51
New cards

public and private modifiers

public:

  • any other class can directly access that object by name

  • classes generally specified as public

  • instance variables usually not public

52
New cards

Encapsulation

consider example of driving a car:

  • we see and use the break pedal, accelerator pedal, and steering wheel - know what they di

  • we do not see mechanical details of how they do their jobs

Encapsulation divides class definition into:

  • class interface (tells what the class does, gives headings for public methods)

  • class implementation (contains private variables, includes definitions and bodies of public and private methods)

A well encapsulated class:

  • all classes, methods, instance variables, class variables, and significant portions of code are commenyed in plain, easy to understand, english

  • well named variables and indentifiers

53
New cards

UML Class Diagrams

  • contains an outline of a class

54
New cards

Primitive type vs class type variables

Value of primitive type stored in the memory location assigned to the variable

Variable of class type contains memory address (references) of object named by the variable

55
New cards

null

null is a special predefined constant that represents a memory address that does not point anywhere

56
New cards

Math.random()

  • returns a pseudorandom double that is greater than or equal to 0 and less than 1

  • 6 sided die:

  • int die = (int) (6.0 * Math.random()) + 1;

57
New cards

Wrapper Classes

  • allows programmer to have an object that corresponds to value of primitive type

  • contain useful predefined constants and methods

  • ex. toUpperCase

58
New cards
59
New cards

Overloading Basics

  • when two or more methods have the same name within the same class

  • Java distinguishes the methods by number and types or parameters

  • a method’s name and number and type of parameters is called its signature

  • if it cannot match a call with a defintion, then it will attempt a type conversion

  • you must not overload a method where the only difference is the type of value returned

60
New cards

Create 2d Array

knowt flashcard image
61
New cards

Bubble Sort

comparing and/or swapping each element until it is sorted

62
New cards

Selection Sort

look for smallest value, place it at the first index, then find the smallest value from the second spot to the end of the list, and place it at the second spot, continue to sorted

63
New cards

Insertion Sort