Review Flashcards

1
Q

The format specifier ________ is a placeholder for an int value.

A

%d

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

What would be displayed as a result of executing the following code?
final int x = 22, y = 4;
y += x;
System.out.println(“x = “ + x + “, y = “ + y)

A

Error because named constants with final

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

What is the value of z after the following code is executed?
int x = 5, y = 28;
float z;
z = (float) (y / x);

A

5.0

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

How many times will the following do-while loop be executed?
int x = 11;
do
{
x += 20;
} while (x > 100);

A

1

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

int x, y = 15;
x = y–;

A

15

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

Scanner keyboard = new Scanner(System.in);
System.out.print(“Enter a number: “);
int number = keyboard.nextInt();
while (number < 100 || number > 500)
{
System.out.print(“Enter another number: “);
number = keyboard.nextInt();
}

A

range 100-500

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

public static double methodA()
{
double a = 8.5 + 9.5;
return a;
}

A

18.0

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

int x = 11;
do
{
x += 20;
} while (x <= 100);

A

5

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

int temp = 200;

if (temp > 90) {
System.out.println(“This porridge is too hot.”);
}

if (temp < 70) {
System.out.println(“This porridge is too cold.”);
}
if (temp == 80) {
System.out.println(“This porridge is just right!”);}

A

The porridge is too hot

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

The empty statement is denoted by what symbol?

A

semicolon

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

a counter-controlled iteration is also known as

A

definite iteration

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

System.out.printf(“%s”, “I love “, “Java”);

A

i love

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

In a class containing methods with the same name, the methods are distinguished by ________.
Number of arguments
Types of arguments
Return type
(a) and (b)
(b) and (c)

A

a and b

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

math methods

A

min(), max(), avg(), sin(), cos(), tan(), round(), ceil(), floor(), abs() etc.

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

Which of the following methods is not in the Math class?
ceil
abs
parseInt
Log

A

parseInt

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

Overloaded methods always have the same _________.
method name
return type
number of parameters
order of the parameters

A

method name

17
Q

Which of the following promotions of primitive types is not allowed to occur?
char to int.
double to float.
int to double.
short to long.

A

double to float

18
Q

Stacks

A

Lifo

19
Q

Any field declared with keyword ________ is constant.
static
const
constant
Final

A

final

20
Q

Which is a correct static method call of Math class method sqrt?
sqrt(900);
math.sqrt(900);
Math.sqrt(900);
Math math = new Math(); math.sqrt(900);

A

Math.sqrt(900);

21
Q

Which expression is equivalent to if (!(grade == sentinelValue))?
if (grade !== sentinelValue)
if (grade != sentinelValue)
! if (grade == sentinelValue)
! if (grade !== sentinelValue)

A

B if (grade != sentineValue)