Questions from Quiz 1 + Quiz 2 Flashcards

1
Q

Which of the following is a constant, according to Java naming conventions?

read

MAX_VALUE

Test

!ReadInt

A

MAX_VALUE

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

Which of these data types requires the least amount of memory?

short

double

byte

float

A

byte

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

_____ are valid Java identifiers.

4+4

3ere

RE4$

int

A

RE4$

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

A Java interpreter is a program that translates Java source code into Java bytecode.

True

False

A

False

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

The compiler checks _______.

syntax errors

runtime errors

logic errors

A

Syntax Errors

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

________ is invoked to create an object.

The main method

A constructor

A method with a return type

A method with the void return type

A

A constructor

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

If you attempt to add an int, a byte, a long, and a float, the result will be a __________ value.

float

double

int

long

A

float

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

If the computer displays an error message while executing your program, the program contains a(n) __________.

run-time error

hidden error

logic error

syntax error

A

run-time error

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

What is the output for the following segment of code

intnum = 3, intNum = 1, intVal = 2, total = 0;

    total += intnum++ * 5;

    System.out.print("intNum : " + intNum + " intVal : " + intVal );

    System.out.println(" Total: " + total);
A

intNum : 1 intVal : 2
total : 15

because intnum++ in:
total += intnum++ * 5;

intnum ++ will use the current value of intnum in the operation then add 1 to it after the operation.

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

Analyze the following code:

public class Test {
private int t;

public static void main(String[] args) {
int x;
System.out.println(t);
}
}

Options:
The variable t is private and therefore cannot be accessed in the main method.

The program compiles and runs fine.

The variable x is not initialized and therefore causes errors.

The variable t is not initialized and therefore causes errors.

t is non-static and it cannot be referenced in a static context in the main method.

A

t is non-static and it cannot be referenced in a static context in the main method.

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