AP Computer Science A #1

This AP Course series is based on computers, and all the answers are based on Java, just to clarify, because some parts of Java share features with other coding languages. One more thing: This quiz is heavily based off of Units 1 and 2, know those well. Good luck!
Quiz by
PastimeQuizzer16
Rate:
Last updated: October 8, 2023
You have not attempted this quiz yet.
First submittedOctober 2, 2023
Times taken182
Average score60.0%
Report this quizReport
4:00
The quiz is paused. You have remaining.
Scoring
You scored / = %
This beats or equals % of test takers also scored 100%
The average score is
Your high score is
Your fastest time is
Keep scrolling down for answers and more stats ...
1. Which of the following is a reference data type?
boolean
int
String
double
2. Which of the following describes a void method?
A method that doesn't print/return any data type
A method that prints a data type but doesn't return it
A method that both prints and returns data types
A method that returns a data type but doesn't print it
3. Which of the following is a proper way to declare a scanner?
Scanner correctAnswer = new Scanner(System.in)
Scanner maybeTheCorrectAnswer = new.Scanner(System.in);
Scanner definitelyTheWrongAnswer = new System.in(Scanner)
Scanner maybeTheWrongAnswer = new Scanner(System.in);
4. Which of the following is a proper way to collect user input through a scanner variable by the name of smartyPants?
int userNum = smartyPants.nextDouble();
int numUser = numUser.nextDouble(smartyPants);
boolean userVerification = nextInt.smartyPants();
double userDoub = smartyPants.nextDouble();
5. Which of the following isn't a function in the math class?
Math.round
Math.abs
Math.pow
Math.int
6. I have declared a string variable called word that is initialized as "Super". If I were to use the substring function and enter the parameters 1 and 3 respectively, what would be the output if printed?
Super
upe
1,3
Sup
7. I worked really hard on a program to compute the area of a square using user input, but it just WON'T WORK OUT! Here is my code: Scanner newDim = new Scanner(System.in); System.out.println("Enter a side of your square."); side = newDim.nextDouble(); area = Math.pow(side,2.0); System.out.println("Area:" + area); PLEASE HELP ME SOLVE THIS IM FREAKING OUT. MY THERAPIST IS SAYING THERE IS MORE THAN ONE ERROR SELECT THE OPTION THAT PINPOINTS BOTH ERRORS.
You haven't stated what data type area and side are. They should be doubles.
You can't declare your scanner variable a name of your choice. It must be called input.
nextDouble isn't a real statement in Java. You must find another way to store the input.
You can't print a string and a double together. Convert the double into a string.
8. Which of the following successfully calls a method by the name of jetPunk?
jetPunk();
start jetPunk();
jetPunk()
calledMethod = jetPunk()
9. Which of the following variables can store a value of 3.6?
int
char
boolean
double
10. Which of the following functions aren't in the String class?
String.spellOut
String.indexOf
String.subString
String.charAt
Save Your Stats
Your Next Quiz
How many countries do you know? In this quiz, you've got 15:00 to name as many as you can. Go!
Can you name the capitals cities of all 196 countries in the world?
20 random countries have been removed from the map of the world! Can you identify them in 3 minutes?
Drag the pin onto the correct country. Careful, though! Three wrong moves and the game ends.
2 Comments
+1
Level 67
Oct 8, 2023
You have the wrong answer marked in Question 4. Coercing a double into an int is not proper. On most compilers, it will not even compile.
+1
Level 31
Oct 8, 2023
My apologies, I just fixed it.