100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
AP Computer Science A Final Exam Review Questions and Answers $11.99   Add to cart

Exam (elaborations)

AP Computer Science A Final Exam Review Questions and Answers

 7 views  0 purchase
  • Course
  • AP Computer Science
  • Institution
  • AP Computer Science

AP Computer Science A Final Exam Review Questions and Answers

Preview 3 out of 18  pages

  • July 30, 2024
  • 18
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
  • AP Computer Science
  • AP Computer Science
avatar-seller
millyphilip
AP Computer Science A Final Exam Review Questions and Answers
What is the data type of the following literal?
"fooled you" - Answer -string
What is the camel case variable name for a variable that represents the top score? - Answer -topScore
What are the three primitive data types that will be tested on the AP Exam? - Answer -
double boolean int
What is the camel case variable name for a variable that represents a shoe size? - Answer -shoeSize
What data type should you use to represent the average grade for a course? - Answer -
double
What data type should you use for a shoe size like 8.5? - Answer -double
What data type should you use to record if it is raining or not? - Answer -boolean
What is the data type of the following literal?
'A' - Answer -char
What data type holds true/false values? - Answer -boolean
What data type should you use to represent the amount of money in a bank account? - Answer -double
Which of the following is NOT the name of a Java primitive data type? - Answer -String
What are the two varieties of data in Java? - Answer -objects and primitive
Which of the following is the correct header line for the main method in Java? - Answer -
public static void main (String args [])
A ______ is a note written to a human reader of a program. - Answer -comment Which of the following will result in an error? - Answer -12 + (13 + 7)/2 ) * 4
What are the two steps that take place when an assignment statement is executed? - Answer -(i) Evaluate the Expression, and (ii) Store the value in the variable.
On a single line of code declare x, y, and z all to be an integer data type. - Answer -int x,
y, z;
(2 - 6) / 2 + 9 - Answer -7
Which of the following is legal? - Answer -x=9
State what is printed.
int x = 40;
int y = 4;
System.out.println(2 + 8 * y / 2 - x); - Answer --22
What is the value of the expression:
-5 * + 10 * - Answer -1
On a single line of code declare x, y, and z to be double and on that same line initialize them all to be 3.14. - Answer -double x = 3.14, y = 3.14, z = 2.14;
State what is printed.
int a = 100;
int b = 200;
b/=a;
System.out.println(b + 1); - Answer -3
What is another way to write p = p - 1;? - Answer -p--;
The following code stores a 20 in the variable num;
double num = 61/3;
What small change can you make to this single line of code to make it produce the "real" answer to the division? - Answer -double num = (double) 61/3;
State what is printed.
System.out.println((double)(90/9)); - Answer -10.0
Write code that will calculate and print the square root of 435.61. - Answer -
System.out.println(Math.sqrt(435.61));
Which of the following would return a random number from 1 to 6 inclusive? - Answer -
What is the purpose of wrapper classes? - Answer -to convert primitive type variables into objects containing the equivalent information. Write a Java formula using the Math class for:
Distance = |val1 - val2| - Answer -Math.abs(val1-val2)
Evaluate:
Math.ceil(115.8) - Answer -116.0
Evaluate:
Math.abs(2 + -4) - Answer -2
Evaluate:
Math.sqrt(16) * Math.max(Math.abs(-5), Math.abs(-3)) - Answer -20.0
The classes that convert primitives to objects are called _____ classes - Answer -
wrapper
Evaluate:
Math.min( 8, 3 + 2 ) - Answer -5
Write a formula that will find the distance between two values, num1 and num2 by taking the absolute value of their difference. Assign the answer to double x. - Answer -
double x = Math.abs(num1-num2)
Evaluate:
Math.sqrt(76 + 45) - Answer -11.0
Which of the following would return a random int from 1 to 10 inclusive? - Answer -(int)
(Math.random()*10)+1
What is the value of len after the following executes?
String s1 = "Love you!";
int len = s1.length(); - Answer -9
What is the value of str2 after the following code executes?
String s1 = "helicopter";
String s2 = s1.substring(4, 7); - Answer -cop
Consider the following code segment.
String s1 = "Queen Mary";
String s2 = "1936 Queen Mary";
String s3 = "Queen Elizabeth";
System.out.print(s2.indexOf(s1) + " ");
System.out.println(s1.indexOf(s3));
What will be output when the code segment executes? - Answer -5 -1
What will be the value of r?

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

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

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

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.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67096 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$11.99
  • (0)
  Add to cart