stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
APCSA Midterm Review Flashcards | StudBud
Explore
/
APCSA Midterm Review
Output?
double x = 5 / 2; System.out.println(x);
APCSA Midterm Review
50 terms
·
StudBud Administration
·
13 plays
Massive Midterm Review
Flashcards
50 cards
F
Practice quiz
P
Host live
L
Questions
50
Answers
1
double x = 5 / 2; System.
out
.println(x);
Error
2.0
2
2.5
2
Output?
19
21
18
20
3
Output?
False
True
4
Output?
true, false
false, true
false, false
true, true
5
What happens when you call methods on objects initialized to null?
Objects can't even be initialized to null...
Return value defaults to 0 for ints, "" for Strings, etc.
Nothing
Error
6
Which of the following is true about methods in the Math class?
They require a Math object to be created first.
Thet must be called on an instance of Math.
Only the methods related to random numbers are static.
Methods in the Math class are static.
7
Output?
Error can't print objects
lesson_2_7.Cheese@13fee20c
Muenster
The cheese is Muenster
8
Output?
huh
freddy
wandamian
Error
9
Output?
531
54321
54210
5421
10
Output?
Programming
Java
rogramming
ava Programming
11
Output?
20
35
38
40
44
6
12
String x = str1.compareTo(str2) + str2.compareTo(str1); // assume str1 and str2 are initialized. what is x?
A positive number
A negative number
0
Positive or negative. There's no way to know
13
Quick maths. What's the output?
81
43
97
29
41
65
14
Output?
F
D
E
A
B
C
15
Output?
bcdef
abcdef
aabbccddeeff
abcdeff
16
Output?
101
1
99
100
17
Output?
Hello
null
Hello, world!
Error can't modify Strings
18
Which of the following statements is true regarding the public and private access modifiers in Java?
A private field can be accessed directly by any class in the same package.
A private method can be accessed by any other class in the same package.
A public field is only accessible within the class it is declared in.
A private method can be accessed by any other class in the same package.
19
Wandamian's last name?
empanada
papaya
guacamole
banana
20
Output?
50
Error
75
25
21
Output?
Camry
Toyota
2008
Overloading error
22
Output?
false false true
true false false
false true true
true true false
23
simplify: (a && (!a || b))
True
a && b
a || b
False
24
int x = 3; x = (double) x; System.
out
.println(x);
3.0
3
Casting error
Assignment error
25
Output?
BelenJesuitSt.IggyPrep
St. IggyBelenJesuitPrep
BelenJesuitPrepSt.Iggy
JesuitSt. IggyBelenPrep
26
Output?
true true
true false
false true
false false
27
int y = 1.0 * (int) Math.
PI
; System.
out
.println(y);
3.1415926535
3.0
Error
3
28
Output?
4
3
5
Error
29
double x = 1; x++; x -= 2; x += 7; x %= 5; System.
out
.println(x);
4.0
2.0
1.0
3.0
30
What is the dot operator NOT used for in Java?
Accessing instance variables of a class.
Performing mathematical operations between two numbers.
Accessing methods of an object.
Accessing static methods or fields of a class.
31
int x = 6 * 4 / 2 % 3 % 0; System.
out
.println(x);
2
Error
1
0
32
Output?
1 3 5 7 9
1 2 4 6 8
1 2 4 8 16
1 2 4 8
33
A(n) _______ is a specific instance of a class with defined attributes.
parameter
object
method
constructor
34
Output?
21 1.01 spud
1.01 21 spud
0 0.99 spud
0.99 0 spud
35
Output?
3
-1
2
1
36
What does Math.random() return?
A random double between 0.0 (exclusive) and 1.0 (inclusive)
A random float between 0.0 and 1.0
A random double between 0.0 (inclusive) and 1.0 (exclusive)
A random integer between 0 and 1
37
Output?
0426
041526
Infinite loop
048121620
38
What package is the String class part of?
java.lang
java.util
java.io
java.text
39
Which applies De Morgan's law correctly?
!(A && B) == (!A && !B)
!(A∣∣B)==(!A∣∣!B)
!(A && B) == (!A || !B)
!(A && B) == (!A || B)
40
Output?
abc
bcd
abcd
bcde
41
Output?
1 3 5
2 4 6
6 5 4 3 2 1
6 4 2
42
Classes in Java are grouped into what?
Projects
Libraries
Methods
Packages
43
Output?
1-2
-1
102
Error
44
How to round negative number x to the nearest int?
Math.floor(x)
(int) x
(int)(x – 0.5)
(int)(x+0.5)
45
Output?
A negative number
0
A positive number
Error
46
System.
out
.print("Hello, \\\"world!\\\"\n");
Hello, \\"world!\\"
Hello, \"world!\"
Hello, \"world!\"n
Hello, \\\"world!\\\"
47
double x = 1 + 3 * 4 / 6 % 7 + 100 % 1; System.
out
.println(x);
2.0
Error
3.0
4.0
48
Which is not a primitive type?
String
float
double
char
boolean
int
49
Which of the following lines of code contains a valid string literal?
System.out.println("Hello, world!);
System.out.println("Hello, world!");
System.out.println('Hello, world!');
System.out.println(Hello, world!);
50
int fubar = (int) Math.
sqrt
(2)) * 3 / 2; System.
out
.println(fubar);
1
2
0
3