CSC 222 Final Exam Review

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

1/231

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.

232 Terms

1
New cards

What is an Array?

It is an ordered list of items of a given data type

2
New cards

What is each item in an array called?

An element

3
New cards

How do you declare an Array in Java?

dataType[] arrayName = new dataType[numElements];

4
New cards

Why does the array declaration use [] after the data type?

To indicate that the variable is an array refence

5
New cards

All arrays are which type? Primitive or Reference?

Reference

6
New cards

True or False? Arrays are Immutable

True

7
New cards

The array reference variable is assigned to do what?

To refer to that newly allocated array

8
New cards

What is one powerful aspect of arrays? (provides an example to help)

The index is an expression. Ex: userNums[i] uses the value held in the int variable i as the index. As such, an array is useful to easily lookup the Nth item in a list

9
New cards

True or False: The array's index must be a double type

False. It must be integer

10
New cards

How can you tell how many elements are in an array?

Using arrayname.length

11
New cards

Is arrayname.length a method or a property?

A property

12
New cards

The default element for int and double is ___ and the default element for boolean is ___? What about char?

0, false, '\u0000'

13
New cards

How do you initialize an array and declare element values? Do you need to specify how many elements are in the array?

To initialize array elements with non-default values, you will specify them with brackets and seperate with commas.

For example,

int[] array = {2, 4, 6, 8};

When declaring an array like this, you can make the array as long as you want with as many elements without specifying.

14
New cards

An array is a data structure that does what?

Represent a collection of the same types of data.

15
New cards

Can I declare an array like this?

double array[];

You are allowed to, but it is not preferred.

16
New cards

How do you create an array of 10 doubles? How do you reference the first element? How do you reference the last element?

Creating:

double[] array = new double[10];

First:

array[0] //(array elements are 0-bound)

Last:

array[9]

17
New cards

True or False: Once an array is created, its size is fixed.

True

18
New cards

How can I find an array's size?

array.length

19
New cards

How can you access the array's elements?

You can access them through the index. The indices are 0-bound.

20
New cards

Can you treat an array element like a variable?

Yes you can.

For example,

array[2] = array[0] + array[1];

In this example, we added the first and second array element, and placed their sum in the third element.

21
New cards

What are the two ways to initialize and declare array elements?

1:

int[] array = new int[4];

array[0] = 2;

array[1] = 4;

array[2] = 6;

array[3] = 8;

2:

int[] array = {2, 4, 6, 8};

22
New cards

Will this work?

int[] array;

array ={2, 4, 6, 8};

No, it won't. It is incorrect syntax.

23
New cards

Use a for loop with an array of 4 elements. This for loop will give all element in the array the value of x.

Ex.

int[] array = new int[4];

x = 5;

for(int i = 0; i < array.length; i++) {

array[i] = x;

}

To print:

for(int i = 0; i < array.length; i++) {

System.out.println(array[i]);

}

/This will print every element of the array on a new line/

24
New cards

Use this card to demonstrate different things you can do with an array.

25
New cards

What do you call for loop that enables you to traverse the complete array sequentially without using an index variable?

(A loop that doesn not need i)

Enhanced for loop (for-each loop)

Ex.

for (int value: array) {

System.out.println(value);

}

//This is an easier way to print an array

26
New cards

For copying arrays...

Refer to lecture 7, slides 47-49

27
New cards

For passing an array through a method...

Refer to lecture 7, slides 50-78

28
New cards

How do you initialize a 2D-Array?

1:

int[][] array = new int[3][3];

array[0][0] = 1;

2:

int[][] array = {

{1, 2, 3},

{4, 5, 6},

{7, 8, 9},

}

29
New cards

Can a 2D array have rows with different lengths?

If so, what is that called?

Yes, they can. Each row is an array itself. They are called ragged arrays.

They are declared as such:

int[][] array = {

{1, 2, 3},

{4, 5},

{6}

}

30
New cards

Use a for loop to initialize all elements of the array with variable x. And print them

int[][] array = new int[4][4];

x = 5;

for (int i = 0; i < array.length; i++) {

for (int j = 0; j < array[i].length; j++) {

array[i][j] = x;

System.out.println(array[i][j]);

}

}

31
New cards

True or false: You can have multidimensional arrays. (like a 3D or 4D array)

True

32
New cards

What does IPO stand for?

Input, Output, and Processing

33
New cards

What is IPO needed for?

Used to identify three key elements of the problem.

Inputs needed to obtain the desired output.

Processes needed to convert the input into the desired output

Outputs needed to solve the problem. May include user prompts.

34
New cards

What are Algorithms and Flowcharts used for?

They are used to map the logic needed to solve the problem

35
New cards

What is the command line/terminal?

The command line or terminal provides a direct interface with the Operating System to call and run programs

36
New cards

What is the Programming Language and Compiler/Interpret used for?

A programming language is needed to give instructions to a computer.

This includes the ability to write, compile, and run programs.

A programming language is a human readable source code that can then be converted into machine code that can beexecuted by the computer.

37
New cards

What is Version control?

Version control software is used to keep track of different versions of the same piece of software.

Think of it like a saving point in your game where you can return to.

An example is Git.

38
New cards

What is a test environment?

Test environments offer controlled environments to help ensure that your program behaves as intended.

39
New cards

What is Unit Testing?

Programs can be broken down into smaller components and tested one piece at a time.

40
New cards

What is an IDE?

Integrated Development Environment = A set of program development tools integrated into a single piece of software.

An IDE normally includes a programming language editor that includes automatic syntax checking, a compiler to convert source code into the appropriate machine code, a runtime environment to test the code, and debugging tools.

41
New cards

What is Debugging?

Debugging is the process of finding and removing/correcting errors in a program.

42
New cards

True or False: Many IDEs offer integrated debugging tools that allow the programmer to step through a program one line at a time.

True

Doing this permits the programmer to check the contents of variables, examine logic, and study the flow of aprogram.

Programmers may also use output statements to follow the flow of their program.

43
New cards

What is an OS?

What are some examples of their services?

Why would that be powerful?

OS monitors the overall activity of the computer and provides services

Memory management

Input/output

Activities

Storage management

Services don't have to be written by each application

44
New cards

What allows you to send command directly to the OS?

The Command Prompt Program

You will only use your keyboard, not your mouse

45
New cards

What is an advantage and disadvantage of the Command Prompt?

Command Prompt works at a lower level than the GUI. This means that you will have more control over the machine.

The disadvantage is that it is less user-friendly

46
New cards

What are the three steps that Java requires to run a program on a computer?

1. Write the program in a human readable form. This program file is called the source code. The source code must have a .java extension

2. The next step is that the java compiler will compile the source code into bytecode. (The compiler is a program that runs on the computer and takes the .java source code file as input and produces a .class bytecode file as output. The name of the Java compiler program, on an MS Windows computer, isjavac.exe. It is executed from the command line as follows: javac MyProgram.java) The output will be filename.class

3. The JVM will then translate the bytecode into the local machine language code and run the program. (The bytecode output file contains the machine language code for the Java Virtual Machine or JVM. The JVM is an interpreter that translates the Java Bytecode into the local machine code in real time. This means that the bytecode is translated into the local machine code while the program is running)

47
New cards

True or False: The source code an only be written using notepad.

False.

Source code can be written using any text editor

Once the program is written and debugged it must be compiled using a Java compiler.

48
New cards

How do you compile a .java file in the command prompt? What is the output?

javac filename.java

Output: filename.class

49
New cards

How do you run a java file? (Assuming it is already compiled)

java filename

The name of the Java runtime program, on an MS Windows computer, is java.exe

It is executed from the command line

50
New cards

The process of compiling your java code and running requires what?

It requires that a Java Development Kit (JDK) be installed on your computer. You must also correctly navigate to the directory where your programs are stored to compile and run your programs.

51
New cards

What is Version Control System?

Version control systems are a category of software tools that helps in recording changes made to files by keeping a track of modifications done in the code

52
New cards

What is Test Bench?

A program whose job is to thoroughly test another program (or portion) via a series of input/output checks known as test cases

53
New cards

To create and run a testbench for a specific item (or "unit") like a method or a class means what?

Unit Testing

54
New cards

What is Regression testing?

It means to retest an item like a class anytime that item is changed; if previously-passed test cases fail, the item has "regressed"

A testbench should be maintained along with the item, to always be used for regression testing

55
New cards

Here are some facts about testbenches.

Testbenches may be complex, with thousands of test cases.

Various tools support testing, and companies employ test engineers who only test other programmers' items. A large percent, like 50% or more, of commercial software development time may go into testing

56
New cards

What is the stages of the Software Development Life Cycle?

Requirements Specification

System Analysis

System Design

Implementation

Testing

Deployment

Maintenance

57
New cards

What is done at the Requirements Specification stage of the Software Development Life Cycle?

A formal process that seeks to understand the problem and document in detail what the software system needs to do. This phase involves close interaction between users and designers

Most of the examples in this book are simple, and their requirements are clearly stated. In the real world, however, problems are not well defined. You need to study a problem carefully to identify its requirements

58
New cards

What is done at the System Analysis stage of the Software Development Life Cycle?

Seeks to analyze the business process in terms of data flow, and to identify the system's input and output.

Part of the analysis entails modeling the system's behavior. The model is intended to capture the essential elements of the system and to define services to the system

59
New cards

What is done at the System Design stage of the Software Development Life Cycle?

The process of designing the system's components.

This phase involves the use of many levels of abstraction to decompose the problem into manageable components, identify classes and interfaces, and establish relationships among the classes and interfaces

The essence of system analysis and design is input, process, and output. This is called IPO.

60
New cards

What is done at the Implementation stage of the Software Development Life Cycle?

The essence of system analysis and design is input, process, and output. This is called IPO.

61
New cards

What is done at the Testing stage of the Software Development Life Cycle?

The process of translating the system design into programs. Separate programs are written foreach component and put to work together

This phase requires the use of a programming language like Java. The implementation involves coding, testing, and debugging

62
New cards

What is done at the Deployment stage of the Software Development Life Cycle?

Ensures that the code meets the requirements specification and weeds out bugs

An independent team of software engineers not involved in the design and implementation of the project usually conducts such testing

63
New cards

What is done at the Maintenance stage of the Software Development Life Cycle?

Deployment makes the project available for use

For a Java program, this means installing it on a desktop or on the Web.

Maintenance is concerned with changing and improving the product

A software product must continue to perform and improve in a changing environment. This requires periodic upgrades of the product to fix newly discovered bugs and incorporate changes

64
New cards

A combination of software development (dev) and operations (ops) is called what?

DevOps

It is defined as a software engineering methodology that aims to integrate the work of development teams and operations teams by facilitating a culture of collaboration and shared responsibility

65
New cards

What is the waterfall methodology?

It is a linear form of project management ideal for projects where the end result is clearly established from the beginning of the project. The expectations for the project and the deliverables of each stage are clear and are required in order to progress to the next phase

Approach: Hands-off; goals and outcome established from the beginning

Flexibility: Low

Requires: Completing deliverables to progress to the next phase

66
New cards

What methodology was developed as a response to Waterfall's more rigid structure?

Agile

In Agile, the team will work on phases of the project concurrently, often with short-term deadlines. Additionally, the team, rather than a project manager, drives the project's direction. This can empower the team to be motivated and more productive, but also requires a more self-directed team.

As a result, it's a much more fluid form of project management. A software development project can take years to complete, and technology can change significantly during that time. Agile was developed as a flexible method that welcomes incorporating changes of direction even late in the process, as well as accounting for stakeholders' feedback throughout the process

Approach: Frequent stakeholder interaction

Flexibility: High

Requires: Team initiative and short-term deadlines

67
New cards

What is Waterfall methodology best suited for?

Waterfall is a linear project progression, so it's best suited for projects with a defined end goal. If a project owner has a clear and specific vision of an app, for example, and is confident it will not change throughout the project development, Waterfall methodologies could be a good system to follow

68
New cards

What is Agile methodology best suited for?

Agile leaves a lot of room to adapt and change course as the project develops. It's better suited for projects where the outcome may be dependent on more research or testing

69
New cards

What about Waterfall and Agile's budget?

The budget for projects using Waterfall methodologies tends to be less flexible because the project is mapped out from the beginning. With Agile, there is more room to change direction as the project develops, so the budget is also subject to change. Similarly, the timeline with Waterfall is set from the start, while it's more flexible with Agile and dependent on how the project develops

70
New cards

True or False: Many programming environments have built in debugging tools that allow programmers to examine their code while it is running

True

71
New cards

This typical debugging tool allows programmers to do what so they can pause in the middle of a program?

Set Breakpoints

A typical debugging tool allows a programmer to set "breakpoints" in their program to pause the program in the middle of a run. While the program is paused the programmer can examine the values in variables or check to see if the program entered a block of code. Debuggers also allow the programmer to step through each line of code to see if the program is behaving as expected. When running in debug mode, the program runs normally when breakpoints are not set or if the line of code where there is a breakpoint is not executed. In the situation where the programmer has set a breakpoint and then run the debugger without the program pausing tells the programmer that that piece of code was skipped over

72
New cards

True or False: Debuggers can find errors

False

Debuggers cannot find errors. They are tools that need to be studied and used with skill. When used properly debuggerscan help the programmer identify where unexpected things are happening in the program

73
New cards

What are break points?

Breakpoints stop you program and allow you to inspect (and moify the data stored in tyour variables)

Stop on a line of source code before it is executed

74
New cards

What is a debug perspective?

A set of sub-windows within Eclipse to support debugging of Java programs

75
New cards

What are stepping commands?

Control the flow of your program after stopping at a breakpoint

Step: execute the current instruction and stop again

Continue: run to the next breakpoint on the end

76
New cards

An algorithm is a sequence of steps for solving a problem. What is a recursive algorithm?

A recursive algorithm is an algorithm that breaks the problem into smaller subproblems and applies the same algorithm to solve the smaller subproblems

77
New cards

At some point, a recursive algorithm must describe how to actually do something, known as the ___?

The Base Case

78
New cards

A method may call other Methods, including itself. When a method calls itself, what is that called?

A recursive method

79
New cards

To trace a recursive method...

Check slides 4-26, lecture 9

80
New cards

What are the two steps that are made in order to accomplish creating a recursive method?

1. Writing the Base case

2. Writing the Recursive case

Write the base case -- Every recursive method must have a case that returns a value without performing a recursive call. That case is called the base case. A programmer may write that part of the method first, and then test. There may be multiple base cases.• Write the recursive case -- The programmer then adds the recursive case to the method

81
New cards

Variables and methods are used in what?

A program

82
New cards

How do programmers keep programs understandable?

To keep programs understandable, programmers often deal with higher-level groupings of those items(items like variables and methods) known as objects

83
New cards

What is an object in programming?

In programming, an object is a grouping of data (variables) and operations that can be performed on that data (methods)

84
New cards

What are the two things that an object consists of?

State and Behavior

State = Variable

Methods = Behavior

85
New cards

What is OOP?

OOP is Object Oriented Programming and it involves programming using objects

An object has a unique identity, state, and behaviors

86
New cards

What is the State of an object?

The variables

The state defines the object.

The state of an object consists of a set of data fields (also known as properties) with their current values

87
New cards

What is the Behavior of an object?

The methods

The behavior defines what the object does.

The behavior of an object is defined by a set of methods

88
New cards

In regards to classes, what is one special type of method?

Constructors

A class provides a special type of methods, known as constructors, which are invoked to construct objects from the class

89
New cards

What does class abstraction mean to do?

Class abstraction means to separate class implementation from the use of the class

90
New cards

True or False: The User does not need to know how the class is implemented.

True

The user of the class does not need to know how the class is implemented. The detail of implementation is encapsulated and hidden from the user

91
New cards

What are field initializers?

A programmer can initialize fields in the field declaration. Any object created of that class type will initially have those values

92
New cards

A constructor is a special method that is has the same name as the class. What do you call a constructor with no input parameters?

A default constructor.

Java provides a special class member method, known as a constructor, that is called when an object of that class type is created, and which can be used to initialize all fields. The constructor has the same name as the class. The constructor method has no return type, not even void. Ex: public Restaurant() {...} defines a constructor for the Restaurant class.

A programmer specifies the constructor that should be called when creating an object.

Ex: Restaurant favLunchPlace =new Restaurant(); creates a new Restaurant object and calls the constructor Restaurant().

If a class does not have a programmer-defined constructor, then the Java compiler implicitly defines a default constructorwith no arguments. The Java compiler also initializes all fields to their default values

93
New cards

True or false: If there are no other constructors in the class, the default constructor is provided automatically.

True

A class may be defined without constructors. In this case, a no-arg constructor with an empty body is implicitly defined in the class. This constructor, called a default constructor, is provided automatically only if no constructors are explicitly defined in the class

94
New cards

How do I declare a reference variable to reference my object?

ClassName objVariable;

Ex:

Car myCar;

95
New cards

How do I declare/create an object in a single step?

ClassName objVariable = new ClassName();

Ex:

Car myCar = new Car();

96
New cards

How do you reference the object's data/variables?

objVariable.data

Ex:

myCar.model

97
New cards

How do you invoke the object's method?

objVariable.methodName(arguements)

Ex:

myCar.go()

98
New cards

In order to trace the code for making objects...

Check slides 18-31, Lecture 10

99
New cards

True or False: A data field of an object can not have reference variables

False

It can have a reference variable, like the string variable

100
New cards

What does null mean?

For whichever data field has null, that means that there is no memory allocated for it

If a data field of a reference type does not reference any object, the data field holds a special literal value, null