
AP Comp Sci Final Review (part I)

Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Michael Courtright
Used 4+ times
FREE Resource
12 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Class, objects, arrays and Strings are examples of:
nonprimitive data types
primitive data types
inheritance
arrays
recursion
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Downcasting, super(), super, extends, interface and implements are examples of:
nonprimitive data types
primitive data types
inheritance
arrays
recursion
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
enhanced for, nested loop, index and length are examples of:
nonprimitive data types
primitive data types
inheritance
arrays
recursion
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
self-calling, base case and StackOverflowException are examples of:
nonprimitive data types
primitive data types
inheritance
arrays
recursion
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
class MCQReview{
int x;
int y;
MCQReview(int x, int y){
this.x = x;
this.y = y; }
void method(){
x += x++ - y/2 + ++y; }
void display(){
System.out.println("x is: " + x);
System.out.println("y is: " + y); }
public static void main(String[] args){
MCQReview m1 = new MCQReview(10,20);
m1.method();
m1.display(); }
}
What will be the output of the above code segment?
x is: 32
y is: 20
x is: 30
y is: 21
x is: 32
y is: 21
x is: 30
y is: 20
x is: 31
y is: 21
Answer explanation
x = 10, y =20
x += x++ - y/2 + ++y;
According to operator precedence and operator associativity,
x = x+ (x++ - y/2 + ++y);
x = 10 + (10 - 20/2 + 21) // internally y and x are incremented by 1
x = 10 + ( 10 - 10 +21) = 10 + (0 +21) = 31
x ++ will first substitute and then increment, whereas ++y will first increment and then substitute.
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
class MCQReview2{
int x; static int y;
void display(){
System.out.println("x is: " + x);
System.out.println("y is: " + y); }
public static void main(String[] args){
MCQReview2 m1 = new MCQReview2();
MCQReview2 m2 = new MCQReview2();
m1.x = 2;
m1.y = 3;
m2.x = 4;
m2.y = 5;
m1.display();
m2.display(); } }
What will be the output of the above code segment?
x is: 4
y is: 3
x is: 4
y is: 5
x is: 2
y is: 3
x is: 2
y is: 3
x is: 2
y is: 5
x is: 4
y is: 5
x is: 2
y is: 4
x is: 3
y is: 5
x is: 2
y is: 3
x is: 4
y is: 5
Answer explanation
x is: 2
y is: 5
x is: 4
y is: 5
The variable y, being static, is a shared copy for all the objects. If one object alters the value, it will modify for both of the objects. The variable x is nonstatic, which means that it is an instance variable, a different copy for different objects.
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Assuming that a and b are declared as valid integer values, which of the following is an equivalent statement for the Java statement below?
(x > 5 && x < 8) || (x > 0 || y < 0)
((x > 0) || (x > 5 && x < 8)) || (y < 0)
(x > 5 && x < 8) && (x > 0)
(y < 0) || (x > 5 && x < 8)
(x < 0 && y > 0) && (x < 5 || x > 8)
Answer explanation
((x > 0) || (x > 5 && x < 8)) || (y < 0)
Using the commutative property, the terms can be switched while maintaining the value. The || operator is used with the commutative property, and the expression with && remains together to follow the laws of logic.
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
C#

Quiz
•
11th Grade
10 questions
AP CS A Unit 6 Quiz PRACTICE

Quiz
•
9th - 12th Grade
12 questions
Java Strings

Quiz
•
9th - 12th Grade
10 questions
Chapter 05 Worksheet

Quiz
•
10th Grade
14 questions
C ++ For Loop

Quiz
•
9th - 12th Grade
12 questions
Praca klasowa C++

Quiz
•
12th Grade
10 questions
Le basi C++

Quiz
•
11th Grade
15 questions
AP Computer Science A Review 1

Quiz
•
10th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
14 questions
Inputs and Outputs: Computer Science Intro

Lesson
•
5th - 9th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade
29 questions
AP CSP Unit 2 Review (Code.org)

Quiz
•
10th - 12th Grade