Search Header Logo

AP Computer Science Midterm Review

Authored by Bill Butterfield

Computers

10th - 12th Grade

Used 57+ times

AP Computer Science Midterm Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

26 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Which of the following pairs of declarations will cause an error message?

none
I only
II only
II and III only

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

What will be produced by the following statement?

I
II
III
none of these

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

The following code fragment outputs "13 / 5 = 2.0", however the programmer wanted it to output "13 / 5 = 2.6". Which of the following will NOT correct the error?

double answer = ( double ) 13 / 5;
double answer = 13 / ( double ) 5;
double answer = 13.0 / 5;
double answer = ( double ) ( 13 / 5 );

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Expressions follow order of operations rules. What value will result hold after this statement is executed?

-5
0
13
12

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Suppose that addition and subtraction had higher precedence than multiplication and division. What would the following expression evaluate as?
(hint: Use parentheses to elevate the rank of addition and subtraction operations)

7
8
0
1

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Assume aNum is a variable of type double that is positive. A program contains the boolean expression (Math.pow( aNum, 0.5 ) == Math.sqrt ( aNum )). Even though aNum1/2 is mathematically equivalent to √aNum the above expression returns the value false in a student's program. Which of the following is the most likely reason?

Math.pow returns an int, while Math.sqrt returns a double.
aNum was imprecisely calculated in a previous program statement.
The computer stores floating-point numbers with 32-bit words.
There is round-off error in calculating the pow and sqrt functions.

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

If a is of type int and has a value of 0 when the segment is executed, what will happen?

An ArithmeticException will be thrown.
statement2, but not statement1, will be executed.
statement1, but not statement2, will be executed.
A syntax error will occur.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?