Presentation is loading. Please wait.

Presentation is loading. Please wait.

Take out a piece of paper and PEN.

Similar presentations


Presentation on theme: "Take out a piece of paper and PEN."— Presentation transcript:

1 Take out a piece of paper and PEN.
Exposure Java 2015 for Teaching AP® Computer Science DYRT Quiz Key Take out a piece of paper and PEN. The quiz starts TWO minutes after the tardy bell rings. You will have 30 seconds per question.

2 Title the quiz as shown below The quiz starts in ONE minute.
Name Period Date Quiz 15.

3 Question 01 What is the output of the following program segment?
int[ ] list = {1,2,3,4,5,6,7,8,9}; for (int number : list) { number++; System.out.print(number + " "); } Runtime exception error

4 Question 02 What is the output of the following program segment?
int[ ] list = {1,2,3,4,5,6,7,8,9}; for (int number : list) number++; for (int number : list) System.out.print(number + " "); Runtime exception error

5 Question 03 What is the output of the following
Program segment and method? int p = 10; int q = 20; swap(p,q); System.out.println(p + " " + q); public static void swap (int x, int y) { int temp = x; x = y; y = temp; } 10 20 20 10 10 10 20 20

6 Question 04 What is the output of the following
Program segment and method? int p = 10; int q = 20; swap(p,q); public static void swap (int x, int y) { int temp = x; x = y; y = temp; System.out.println(x + " " + y); } 10 20 20 10 10 10 20 20

7 Question 05 What is the output of the following
Program segment and method? int[ ] list = {111,222,333,444,555}; swap(list,3,4); System.out.println(list[2]+" "+list[3]); public static void swap(int[ ] x, int p, int q) { int temp = x[p]; x[p] = x[q]; x[q] = temp; } Runtime Exception error

8 Question 06 What is the output of the following
Program segment and method? int[ ] list = {111,222,333,444,555}; swap(list,1,5); System.out.println(list[2]+" "+list[4]); public static void swap(int[ ] x, int p, int q) { int temp = x[p]; x[p] = x[q]; x[q] = temp; } Runtime Exception error

9 Question 07 “Shallow” values are used by
simple, primitive data types only. objects only. simple data only when passing parameters. objects only when passing parameters. both simple data types and objects.

10 Question 08 “Deep” values are used by
simple, primitive data types only. objects only. simple data only when passing parameters. objects only when passing parameters. both simple data types and objects.

11 Question 09 The Card class stores information about
the number of cards in a deck. its location in a deck. its suit, rank and value. its suit color. all of the above.

12 Question 10 The toString method in the Card class is used
for constructing a Card object. for displaying any String attribute values. for displaying the three attribute values. in place of the println method for output. for all of the above.

13 Question 11 The Card class and the Deck class have
class interaction with composition. class interaction with inheritance no class interaction only class interaction between Card objects.

14 Question 12 In any of the Deck class program examples the
call to construct a Card object is located in the Deck class only. the DeckTester class only. either the Deck or DeckTester classes. none of the above.

15 Question 13 In any of the Deck class program examples the
call to construct a cards array object is located in the Deck class only. the DeckTester class only. either the Deck or DeckTester classes. none of the above.

16 Question 14 In any of the Deck class program examples the
call to construct a Deck object is located in the Deck class only. the DeckTester class only. either the Deck or DeckTester classes. none of the above.

17 Question 15 The toString method of the Deck class
uses the toString method of the Card class. displays all the cards in the Deck object. returns a concatenated string of Card objects. does all of the above.

18 Question 16 The size value of a Deck object Is fixed at 1.
is not an attribute of the Deck class. is between 0 and 52.


Download ppt "Take out a piece of paper and PEN."

Similar presentations


Ads by Google