Test Review CSC 115 Midterm 1 Flashcards

Test Prep

1
Q

How to print in Java?

A

System.out.println()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a Java program always start with?

A

Class Declaration with Class name(public class _____)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the equivalent of functions(blocks of code) in Java?

A

Methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Allows us to convert a value from one type to another

A

Casting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Converting a variable to another of higher precision

A

Implicit casting

Example:
int i = 4;
double j = i; // j is 4.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Forcing the conversion of a variable to a specified type

A

Explicit casting

Example:
double x = 4.95; // x is 4.95
int y = (int) x; // y is 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to declare Methods?

A

public static <returnType> <name> (<parameters>) {
statement inside method;
}</parameters></name></returnType>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

“and” operator

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

“or” operator

A

||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. Always execute the block of code once
  2. and continue to execute the block of code as long as a specified condition is met
A

do-while loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to declare an array if we know what values to put in it?

A

type[] name = {<comma>};</comma>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to declare an array if we don’t know what values to put in it(only know the size or know nothing at all)?

A

type[] name = new type[<size>];</size>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What can we use to determine the length of an array?

A

int[] numsArray = {7, 9, 6, 4};
System.out.println(numsArray.length); //outputs 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to declare Multi-dimensional Arrays?

A

int c[][] = new int[3][4];
or
int c[][] = {{1, 2}, {3, 4, 5}, {6, 7}, {8, 9, 10}};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Error caused by improperly formatted code(missing semicolons/wrong capitalizations)

A

Syntax errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Error caused by the incorrect way we are trying to
use a variable or object (out of bound indexes for arrays)

A

Runtime errors

17
Q
A