AP Computer Science Final Exam with correct Answers
Inheritance is the process of sharing methods and instance variables between a base class
and its subclasses (T/F). - Answer -True
The name of the text file with Java source code must match the name of the program with a
.class extension (T/F). - Answer -False
Both for loops and while loops can be used as count-controlled loops (T/F). - Answer -
True
It is illegal to declare several variables in a single declaration, i.e. int a, b, c; - Answer -
False
m++, m=m+1, and m+=1 are all equivalent expressions (T/F). - Answer -True
The assignment operator ( = ) and equal to operator ( == ) can be used interchangeably
(T/F). - Answer -False
A while loop will always execute at least once (T/F). - Answer -False
The counter in a for loop is updated at the beginning of the loop (T/F). - Answer -False
It is illegal to declare the loop control variable inside the for loop header (T/F). - Answer -False
The for statement combines counter initialization, condition test and counter update into a single expression (T/F). - Answer -True
It is usually safer to use the == or != operators in loops, rather than the other logical operators (T/F). - Answer -False
The identity of an object is simply the variable that references the object (T/F). - Answer -False A class's implementation details can be changed radically without affecting any of its clients provided its interface remains the same (T/F). - Answer -True
The keyword public indicates that the class is accessible to all potential clients (T/F). - Answer -True
Constructors do not have return types, but all other methods do (T/F). - Answer -True
A class can include only one constructor (T/F). - Answer -False
A method can only have one return statement (T/F). - Answer -False
The OR operand evaluates to false if one operand is false (T/F). - Answer -False
Nested if statements offer an alternative to deal with a programs logical complexity (T/F). - Answer -True
Java uses complete evaluation, in which all parts of a Boolean expression are always evaluated (T/F). - Answer -False
Consider the following code segment:
int x = 7;
int y = 3;
if ( (x<10) && (y<0) )
System.out.println("Value is: " +x*y);
else
System.out.println("Value is: " + x/y); - Answer -Value is: 2
Assume that a and b have been defined and initialized as int values. The expression
!(! (a!=b) && (b>7))
is equivalent to which of the following? - Answer -(a != b) || (b <= 7)
Consider the following code segment.
int sum = 0;
int k =1;
while (sum < 12 || k<4)
sum += k;
System.out.println(sum);
What is printed as a result of executing the code segment? - Answer -Nothing is printed due to an infinite loop.
Consider the following code segment.
int num = 2574;
int result = 0;
while (num > 0) {
result = result * 10 + num % 10;
The benefits of buying summaries with Stuvia:
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
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
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 millyphilip. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $11.99. You're not tied to anything after your purchase.