Title: CS 61BL Midterm Review
1CS 61BL Midterm Review
2Predict the output
- 1. What is the output of the following
codeSystem.out.println ("ABCDEF".substring(0,4).
substring (1,3)) - Option A Error
- Option B BCD
- Option C CD
- Option D BC
3Predict the output
- 1. What is the output of the following
codeSystem.out.println ("ABCDEF".substring(0,4).
substring (1,3)) - Option A Error
- Option B BCD
- Option C CD
- Option D BC
- ABCDEF.substring(0,4) is the string ABCD
- ABCD.substring(1,3) is the string BC
4What is the printed value of i after the
following code is executed ? public static void
main (String a) int i 5 f
(i) System.out.println("i" i) void f
(int i) i i i
- Option A Error
- Option B i 0
- Option C i 5
- Option D i 25
5What is the printed value of i after the
following code is executed ? public static void
main (String a) int i 5 f
(i) System.out.println("i" i) void
static f (int i) i i i
- Option A Error
- Option B i 0
- Option C i 5
- Option D i 25
6What is the value of s after the following code
is executed ?public static void main (String
a) String s "A" square (s)
System.out.println("s " s) void static
square (String s) s s s
- Option A Error
- Option B s
- Option C s A
- Option D s AA
7What is the value of s after the following code
is executed ?public static void main (String
a) String s "A" square (s)
System.out.println("s " s) void square
(String s) s s s
- Option A Error
- Option B s
- Option C s A
- Option D s AA
8 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s1 s1)
- Option A Error
- Option B true
- Option C false
- Option D ???
9 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s1 s1)
- Option A Error
- Option B true
- Option C false
- Option D ???
10 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s1 s2)
- Option A Error
- Option B true
- Option C false
- Option D ???
11 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s1 s2)
- Option A Error
- Option B true
- Option C false
- Option D ???
12 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s1 s3)
- Option A Error
- Option B true
- Option C false
- Option D ???
13 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s1 s3)
- Option A Error
- Option B true
- Option C false
- Option D ???
14 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s2 s3)
- Option A Error
- Option B true
- Option C false
- Option D ???
15 Predict the output String s0 nullString
s1 "A"String s2 new String ("A")String s3
s1 System.out.println(s2 s3)
- Option A Error
- Option B true
- Option C false
- Option D ???
16 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
j)
- Option A Error
- Option B 5
- Option C 7
- Option D 10
17 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
j)
- Option A Error
- Option B 5
- Option C 7
- Option D 10
18 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
i)
- Option A Error
- Option B 5
- Option C 7
- Option D 10
19 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
i)
- Option A Error
- Option B 5
- Option C 7
- Option D 10
20 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
k)
- Option A Error
- Option B 5
- Option C 7
- Option D 10
21 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
k)
- Option A Error
- Option B 5
- Option C 7
- Option D 10
22 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
i.equals(k))
- Option A Error
- Option B 5
- Option C 7
- Option D 10
23 Predict the output int i 5int j
iint k ii 7j 10 System.out.println(
i.equals(k))
- Option A Error
- Option B 5
- Option C 7
- Option D 10
24Dog is a subclass of Animal Animal a new
Animal()Dog d (Dog) a
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
25Dog is a subclass of Animal Animal a new
Animal()Dog d (Dog) a
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
26Dog is a subclass of Animal Animal a new
Dog()Dog d (Dog) a
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
27Dog is a subclass of Animal Animal a new
Dog()Dog d (Dog) a
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
28Dog is a subclass of Animal Animal aa new
Dog2
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
29Dog is a subclass of Animal Animal aa new
Dog2
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
30Dog is a subclass of Animal BOTH implement
eat( String food) Dog d new Dog()
((Animal) d).eat(kibble)
- Option A Does not compile
- Option B Run time error
- Option C Calls Dogs eat method
- Option D Calls Animals eat method
31Dog is a subclass of Animal BOTH implement
eat( String food) Dog d new Dog()
((Animal) d).eat(kibble)
- Option A Does not compile
- Option B Run time error
- Option C Calls Dogs eat method
- Option D Calls Animals eat method
32Dog is a subclass of Animal Animal aa new
Animal2 aa0 new Dog() aa1 new
Dog()Dog da (Dog ) aa
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
33Dog is a subclass of Animal Animal aa new
Animal2 aa0 new Dog() aa1 new
Dog()Dog da (Dog ) aa
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
34Dog is a subclass of Animal Animal aa new
Dog2 Dog da (Dog ) aa
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know
35Dog is a subclass of Animal Animal aa new
Dog2 Dog da (Dog ) aa
- Option A Does not compile
- Option B Run time error
- Option C Works
- Option D Dont know