CS 61BL Midterm Review - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

CS 61BL Midterm Review

Description:

1. What is the output of the following code: ... (Animal) d).eat('kibble'); Answer. Option A: Does not compile. Option B: Run time error ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 36
Provided by: collee2
Category:
Tags: 61bl | kibble | midterm | review

less

Transcript and Presenter's Notes

Title: CS 61BL Midterm Review


1
CS 61BL Midterm Review
2
Predict 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

3
Predict 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

4
What 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

5
What 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

6
What 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

7
What 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

24
Dog 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

25
Dog 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

26
Dog 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

27
Dog 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

28
Dog 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

29
Dog 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

30
Dog 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

31
Dog 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

32
Dog 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

33
Dog 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

34
Dog 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

35
Dog 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
Write a Comment
User Comments (0)
About PowerShow.com