100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSC 222 Final Exam Review Questions and Answers $12.49   Add to cart

Exam (elaborations)

CSC 222 Final Exam Review Questions and Answers

 7 views  0 purchase
  • Course
  • CSC - Cyber Secure Coder
  • Institution
  • CSC - Cyber Secure Coder

CSC 222 Final Exam Review Questions and Answers What is an Array? It is an ordered list of items of a given data type What is each item in an array called? An element Previous Play Next Rewind 10 seconds Move forward 10 seconds Unmute 0:00 / 0:15 Full screen Brainpower ...

[Show more]

Preview 4 out of 37  pages

  • September 22, 2024
  • 37
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • CSC - Cyber Secure Coder
  • CSC - Cyber Secure Coder
avatar-seller
Pogba119
CSC 222 Final Exam Review Questions
and Answers
What is an Array? - answer It is an ordered list of items of a given data type

What is each item in an array called? - answer An element

How do you declare an Array in Java? - answer dataType[] arrayName = new
dataType[numElements];

Why does the array declaration use [] after the data type? - answer To indicate that
the variable is an array refence

All arrays are which type? Primitive or Reference? - answer Reference

True or False? Arrays are Immutable - answer True

The array reference variable is assigned to do what? - answer To refer to that newly
allocated array

What is one powerful aspect of arrays? (provides an example to help) - answer 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

True or False: The array's index must be a double type - answer False. It must be
integer

How can you tell how many elements are in an array? - answer Using
arrayname.length

Is arrayname.length a method or a property? - answer A property

The default element for int and double is ___ and the default element for boolean is
___? What about char? - answer 0, false, '\u0000'

How do you initialize an array and declare element values? Do you need to specify how
many elements are in the array? - answer 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.

An array is a data structure that does what? - answer Represent a collection of the
same types of data.

Can I declare an array like this?
double array[]; - answer You are allowed to, but it is not preferred.

How do you create an array of 10 doubles? How do you reference the first element?
How do you reference the last element? - answer Creating:
double[] array = new double[10];

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

Last:
array[9]

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

How can I find an array's size? - answer array.length

How can you access the array's elements? - answer You can access them through
the index. The indices are 0-bound.

Can you treat an array element like a variable? - answer 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.

What are the two ways to initialize and declare array elements? - answer 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};

Will this work?
int[] array;

,array ={2, 4, 6, 8}; - answer No, it won't. It is incorrect syntax.

Use a for loop with an array of 4 elements. This for loop will give all element in the array
the value of x. - answer 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*/

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

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) - answer Enhanced for loop (for-each loop)

Ex.
for (int value: array) {
System.out.println(value);
}

//This is an easier way to print an array

For copying arrays... - answer Refer to lecture 7, slides 47-49

For passing an array through a method... - answer Refer to lecture 7, slides 50-78

How do you initialize a 2D-Array? - answer 1:
int[][] array = new int[3][3];
array[0][0] = 1;

2:
int[][] array = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
}

Can a 2D array have rows with different lengths?

, If so, what is that called? - answer 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}
}

Use a for loop to initialize all elements of the array with variable x. And print them -
answer 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]);
}
}

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

What does IPO stand for? - answer Input, Output, and Processing

What is IPO needed for? - answer 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.

What are Algorithms and Flowcharts used for? - answer They are used to map the
logic needed to solve the problem

What is the command line/terminal? - answer The command line or terminal provides
a direct interface with the Operating System to call and run programs

What is the Programming Language and Compiler/Interpret used for? - answer 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.

What is Version control? - answer Version control software is used to keep track of
different versions of the same piece of software.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Pogba119. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

72042 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.49
  • (0)
  Add to cart