29
Exposure Java Multiple Choice Test Chapter 13 Interfaces and Abstract classes This Test Is a KEY This test includes program segments, which are not complete programs. Answer such questions with the assumption that the program segment is part of a correct program. 01. A(n) _______ is a group of objects. ### (A) collection (B) list (C) set (D) interface (E) class 02. A(n) _______ is an unordered collection without any duplicate elements. (A) collection (B) list ### (C) set (D) interface (E) class 03. A(n) _______ is a linear collection that allows access to any element. Duplicates may exist. Exposure Java 2015, APCS Edition Chapter 13 Test Page 1 06-02-15

Exposure C++ - vernonmath.comvernonmath.com/wp/wp-content/uploads/2016/01/Test13Key.docx  · Web viewI.a Java reserved word short for Element. II.a class variable for the data type

Embed Size (px)

Citation preview

Exposure Java Multiple Choice TestChapter

13Interfaces and Abstract classes

This Test Is a KEYThis test includes program segments, which are not complete programs. Answer such questions with the assumption that the program segment is part of a correct program.

01. A(n) _______ is a group of objects.

### (A) collection(B) list(C) set(D) interface(E) class

02. A(n) _______ is an unordered collection without any duplicate elements.

(A) collection(B) list

### (C) set(D) interface(E) class

03. A(n) _______ is a linear collection that allows access to any element. Duplicates may exist.

(A) collection### (B) list

(C) set(D) interface(E) class

Exposure Java 2015, APCS Edition Chapter 13 Test Page 1 06-02-15

04. Java's Collection is a(n)

### (A) interface.(B) subinterface.(C) abstract class.(D) concrete class.(E) subclass.

05. Java's Set is a(n)

(A) interface.### (B) subinterface.

(C) abstract class.(D) concrete class.(E) subclass.

06. Java's List is a(n)

(A) interface.### (B) subinterface.

(C) abstract class.(D) concrete class.(E) subclass.

07. Java's ArrayList is a(n)

(A) interface.(B) subinterface.(C) abstract class.

### (D) concrete class.(E) subclass.

Exposure Java 2015, APCS Edition Chapter 13 Test Page 2 06-02-15

08. Java's LinkedList is a(n)

(A) interface.(B) subinterface.(C) abstract class.

### (D) concrete class.(E) subclass.

09. Java's TreeSet is a(n)

(A) interface.(B) subinterface.(C) abstract class.

### (D) concrete class.(E) subclass.

10. Java's HashSet is a(n)

(A) interface.(B) subinterface.(C) abstract class.

### (D) concrete class.(E) subclass.

Exposure Java 2015, APCS Edition Chapter 13 Test Page 3 06-02-15

Questions 11-12 refer to this partial program:public class Q1112{

public static void main (String args[]){

MyBank tom = new MyBank(3000.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.makeCheckingDeposit(1000.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.makeCheckingWithdrawal(5000.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

}}

interface Bank{

public double getCheckingBalance();public void makeCheckingDeposit(double amount);public void makeCheckingWithdrawal(double amount);

}

11. What is the output of this program, if the MyBank class implements the Bank interface in this way?

class MyBank implements Bank{

private double checking;public MyBank(double c) { checking = c; }public double getCheckingBalance() { return checking; }public void makeCheckingDeposit(double amount) { checking += amount; }public void makeCheckingWithdrawal(double amount) { checking -= amount; }

}

(A) Tom's checking balance: 3000Tom's checking balance: 2000Tom's checking balance: 7000

###(B) Tom's checking balance: 3000

Tom's checking balance: 4000Tom's checking balance: -1000

(C) Tom's checking balance: 3000Tom's checking balance: 4000Tom's checking balance: 9000

(D) Tom's checking balance: 3000Tom's checking balance: 4000Tom's checking balance: 4000

12. What is the output of this program, if the MyBank class implements the Bank interface in this way?Exposure Java 2015, APCS Edition Chapter 13 Test Page 4 06-02-15

class MyBank implements Bank{

private double checking;public MyBank(double c) { checking = c;}public double getCheckingBalance() { return checking; }public void makeCheckingDeposit(double amount) { checking -= amount; }public void makeCheckingWithdrawal(double amount) { checking += amount; }

}

###(A) Tom's checking balance: 3000

Tom's checking balance: 2000Tom's checking balance: 7000

(B) Tom's checking balance: 3000Tom's checking balance: 4000

Tom's checking balance: -1000

(C) Tom's checking balance: 3000Tom's checking balance: 4000Tom's checking balance: 9000

(D) Tom's checking balance: 3000Tom's checking balance: 4000Tom's checking balance: 4000

Questions 13-14 refer to this partial program:public class Q1314{

public static void main (String args[]){

MyBank tom = new MyBank(5000.0); System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

tom.makeCheckingDeposit(1500.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.makeCheckingWithdrawal(2500.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

}}

abstract interface Bank{

public abstract double getCheckingBalance();public abstract void makeCheckingDeposit(double amount);public abstract void makeCheckingWithdrawal(double amount);

}

13. If the MyBank class implements the Bank interface with these methods, will the program compile?

Exposure Java 2015, APCS Edition Chapter 13 Test Page 5 06-02-15

class MyBank implements Bank{

private double checking;public MyBank(double c) { checking = c; }public double getCheckingBalance() { return checking; }public void makeCheckingDeposit(double amount) { checking += amount; }public void makeCheckingWithdrawal(double amount) { checking -= amount; }

}

### (A) Yes

(B) No

14. If the MyBank class implements the Bank interface with these methods, will the program compile?

class MyBank implements Bank{

private double checking;public MyBank(double c) { checking = c; }public double getCheckingBalance() { return checking; }public void makeCheckingDeposit(double amount) { checking += amount; }

}

(A) Yes

### (B) No

Questions 15-16 refer to this program:public class Q1516

Exposure Java 2015, APCS Edition Chapter 13 Test Page 6 06-02-15

{public static void main (String args[]){

BankAccounts tom = new BankAccounts(4000.0,6000.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.makeCheckingDeposit(1000.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.makeCheckingWithdrawal(2000.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

System.out.println(); System.out.println("Tom's savings balance: " + tom.getSavingsBalance());

tom.makeSavingsDeposit(3000.0);System.out.println("Tom's savings balance: " + tom.getSavingsBalance());tom.makeSavingsWithdrawal(4000.0);System.out.println("Tom's savings balance: " + tom.getSavingsBalance());

}}

abstract interface Checking{

public abstract double getCheckingBalance();public abstract void makeCheckingDeposit(double amount);public abstract void makeCheckingWithdrawal(double amount);

}

abstract interface Savings{

public abstract double getSavingsBalance();public abstract void makeSavingsDeposit(double amount);public abstract void makeSavingsWithdrawal(double amount);

}

class BankAccounts implements Checking, Savings{

private double checking;private double savings;

public BankAccounts(double c, double s) { checking = c; savings = s; }public double getCheckingBalance() { return checking; }public double getSavingsBalance() { return savings; }public void makeCheckingDeposit(double amount) { checking += amount; }public void makeSavingsDeposit(double amount) { savings += amount; }public void makeCheckingWithdrawal(double amount) { checking -= amount; }public void makeSavingsWithdrawal(double amount) { savings -= amount; }

}

15. What is the output of the program on the previous page?

###Exposure Java 2015, APCS Edition Chapter 13 Test Page 7 06-02-15

(A) Tom's checking balance: 4000Tom's checking balance: 5000Tom's checking balance: 3000

Tom's savings balance: 6000Tom's savings balance: 9000Tom's savings balance: 5000

(C) Tom's checking balance: 6000Tom's checking balance: 9000Tom's checking balance: 5000

Tom's savings balance: 4000Tom's savings balance: 5000Tom's savings balance: 3000

(B) Tom's checking balance: 4000Tom's checking balance: 3000Tom's checking balance: 5000

Tom's savings balance: 6000Tom's savings balance: 5000Tom's savings balance: 9000

(D) Tom's checking balance: 6000Tom's checking balance: 5000Tom's checking balance: 9000

Tom's savings balance: 4000Tom's savings balance: 3000Tom's savings balance: 5000

(E) Compile Error. A class cannot implement multiple interfaces.

16. You want to add a method called transferToChecking that will transfer a specific amount of money from the savings account to the checking account.Which of the following methods is the BEST implementation for this method?

(A)public void transferToChecking(double amount){

checking -= amount;savings += amount;

}

(B)public void transferToChecking(double amount){

checking += amount;savings -= amount;

}

(C)###public void transferToChecking(double amount){

if (savings >= amount){

checking += amount;savings -= amount;

}else

System.out.println("Insufficient Funds");}

(D)public void transferToChecking(double amount){

if (savings > amount){

checking += amount;savings -= amount;

}}

Questions 17-20 refer to this program:public class Q1720{

Exposure Java 2015, APCS Edition Chapter 13 Test Page 8 06-02-15

public static void main (String args[]){

MyBank tom = new MyBank(7000.0); System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

tom.makeCheckingDeposit(2500.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.makeCheckingWithdrawal(1500.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.computeInterest();System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

}}

abstract interface Bank{

public final double rate = 0.05;public abstract double getCheckingBalance();public abstract void makeCheckingDeposit(double amount);public abstract void makeCheckingWithdrawal(double amount);public abstract void computeInterest();

}

class MyBank implements Bank{

private double checking;private double interest;

public MyBank(double c){

checking = c;interest = 0.0;// rate = 0.1;

}

public double getCheckingBalance() { return checking; }public void makeCheckingDeposit(double amount) { checking += amount; }public void makeCheckingWithdrawal(double amount) { checking -= amount; }public void computeInterest(){

interest = checking * rate;checking += interest;

}}

17. Will the program on the previous page compile as is?

Exposure Java 2015, APCS Edition Chapter 13 Test Page 9 06-02-15

### (A) Yes

(B) No

18. Will the program on the previous page compile if the keyword final is removed from the Bank interface?

### (A) Yes

(B) No

19. Will the program on the previous page compile if the comment symbol (//) is removed from the MyBank constructor statement // rate = 0.1?

(A) Yes

### (B) No

20. Will the program on the previous page compile if the keyword final is removed from the Bank interfaceand the comment symbol (//) is removed from the MyBank constructor?

(A) Yes

### (B) No

21. Abstract classes

(A) require abstract methods only.

Exposure Java 2015, APCS Edition Chapter 13 Test Page 10 06-02-15

(B) must implement all interface methods.### (C) involve both implementation and inheritance.

(D) are used with composition only.(E) are required for polymorphism.

22. The reserved word abstract - in an abstract class declaration - is

(A) optional, just like an interface.### (B) required for every abstract method in the class.

(C) required for the class heading only.(D) required for adapter classes only.(E) required for the class heading and for every method in the class.

Questions 23-24 refer to these declarations:

abstract class Bank1{

public abstract double getCheckingBalance();public abstract void makeCheckingDeposit(double amount);public abstract void makeCheckingWithdrawal(double amount);

}

abstract interface Bank2{

public abstract double getCheckingBalance();public abstract void makeCheckingDeposit(double amount);public abstract void makeCheckingWithdrawal(double amount);

}

23. Functionally, are Bank1 and Bank2 the same?

### (A) Yes, they are.(B) No, because the interface declaration does not require the abstract reserved words.(C) No, because the abstract class declaration does not require the abstract reserved words.(D) No, because an abstract class always must implement an interface.(E) No, because an abstract class always must extend an interface.

24. Syntactically, are Bank1 and Bank2 the same, except for the words interface and class?

(A) Yes they are.### (B) No, because the interface declaration does not require the abstract reserved words.

Exposure Java 2015, APCS Edition Chapter 13 Test Page 11 06-02-15

(C) No, because the abstract class declaration does not require the abstract reserved words.(D) No, because an abstract class always must implement an interface.(E) No, because an abstract class always must extend an interface.

Questions 25 - 26 refer to this program:public class Q2526{

public static void main (String args[]){

MyBank tom = new MyBank(5000.0); System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

tom.makeCheckingDeposit(2500.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());tom.makeCheckingWithdrawal(1500.0);System.out.println("Tom's checking balance: " + tom.getCheckingBalance());

}}

abstract class Bank{

public abstract double getCheckingBalance();public abstract void makeCheckingDeposit(double amount);public abstract void makeCheckingWithdrawal(double amount);

}class MyBank extends Bank{

private double checking;public MyBank(double c) { checking = c; }public double getCheckingBalance() { return checking; }public void makeCheckingDeposit(double amount) { checking += amount; }public void makeCheckingWithdrawal(double amount) { checking -= amount; }

}

25. What is the output of this program?

(A) Tom's checking balance: 5000Tom's checking balance: 7500Tom's checking balance: 9000

Exposure Java 2015, APCS Edition Chapter 13 Test Page 12 06-02-15

(B) Tom's checking balance: 5000Tom's checking balance: 9000Tom's checking balance: 7500

### (C) Tom's checking balance: 5000Tom's checking balance: 7500Tom's checking balance: 6000

(D) Tom's checking balance: 5000Tom's checking balance: 6000Tom's checking balance: 7500

26. What would be the result of changing the keyword extends to implements in the definitionof MyBank?

(A) The output would be the same as the previous question.

### (B) The program will not compile.

(C) The program will compile, execute, and crash immediately.

(D) The program will execute, display the same output as the previous program, and then crash.

(E) The program will execute, display different output from the previous program, and then crash.

27. Which of the following can contain abstract methods?

I. concrete classesII. interfacesIII. abstract classes

(A) I only(B) II only(C) III only

### (D) II and III only(E) I, II and III

Questions 28 - 30 refer to this travel program:Traveling, like many things in life, resemble the abstractness and concreteness of programming.

For instance, on an international trip you may need the following:Arrange flightsPurchase train tickets

Exposure Java 2015, APCS Edition Chapter 13 Test Page 13 06-02-15

Get documentation ready, like passports and visasExchange dollars into local currencyReserve hotelsBook excursions at different sites of interestLearns a few phrases in language of the countries you are visiting

28. Suppose that you run a travel agency specializing in European travel and you want to create an administrative travel program to keep track of the different aspects of a client's travel. The program starts with the design of an interface to specify the required operations.

Which one of the following represents a correct interface?

###(A)interface Europe{

public void flights(); public void railpass(); public void documentation(); public void money(); public void hotels(); public void excursions(); public void phrases();

}

(B)abstract interface Europe{

public abstract String clientName = "Smith";public abstract void flights();

public abstract void railpass(); public abstract void documentation(); public abstract void money(); public abstract void hotels(); public abstract void excursions(); public abstract void phrases();

}

(C)interface Europe{

public String clientName;

public void flights(); public void railpass(); public void documentation(); public void money(); public void hotels(); public void excursions(); public void phrases();

}

(D)interface Europe{

public Travel() { }

public void flights(); public void railpass(); public void documentation(); public void money(); public void hotels(); public void excursions(); public void phrases();

}

29. A concrete class can be created for each foreign country. At the same time much work can be avoidedby considering what countries have in common. For instance Western Europe has the same money,same documentation requirements and same EurailPass. It makes sense to provide an abstract classbetween the abstract interface and the concrete country classes that implements the common requirements.

Which of the following is an abstract class that will properly implement the common methods?

(Note for experienced travelers. Yes there are different Eurail Passes. For this question there is only one.)

Exposure Java 2015, APCS Edition Chapter 13 Test Page 14 06-02-15

(A)abstract class WestEurope implements Europe{

public abstract void railpass() { /* assume method is implemented */ }

public abstract void documentation() { /* assume method is implemented */ }

public abstract void money() { /* assume method is implemented */ }

}

(B)class WestEurope implements Europe{

public void railpass() { /* assume method is implemented */ }

public void documentation() { /* assume method is implemented */ }

public void money() { /* assume method is implemented */ }

}

(C)class WestEurope implements Europe{

public void railpass() { /* assume method is implemented */ }

public void documentation() { /* assume method is implemented */ }

public void money() { /* assume method is implemented */ }

public abstract void flights(); public abstract void hotels(); public abstract void excursions(); public abstract void phrases();

}

###(D)abstract class WestEurope implements Europe{

public void railpass() { /* assume method is implemented */ }

public void documentation() { /* assume method is implemented */ }

public void money() { /* assume method is implemented */ }

}

30. Concrete classes must be created for each of the Western European Countries. This is not complete,we now have an abstract class that already has some common methods finished. Only one concreteclass will be shown here.

Which of the following is a concrete class that will properly implement the abstract methods?

###(A)class Italy extends WestEurope

(B)class Italy extends WestEurope

Exposure Java 2015, APCS Edition Chapter 13 Test Page 15 06-02-15

{ private String clientName; public Italy (String clientName) { this.clientName = clientName; } public void flights() { /* assume method is implemented */ }

public void hotels() { /* assume method is implemented */ }

public void excursions() { /* assume method is implemented */ }

public void phrases() { /* assume method is implemented */ }

}

{ private String clientName; public Italy (String clientName) { clientName = clientName; } public void flights() { /* assume method is implemented */ }

public void hotels() { /* assume method is implemented */ }

public void excursions() { /* assume method is implemented */ }

public void phrases() { /* assume method is implemented */ }

}

(C)class Italy implements WestEurope{

private String clientName; public Italy (String clientName) { this.clientName = clientName; } public void flights() { /* assume method is implemented */ }

public void hotels() { /* assume method is implemented */ }

public void excursions() { /* assume method is implemented */ }

public void phrases() { /* assume method is implemented */ }

}

(D)class Italy {

private String clientName; public Italy (String clientName) { this.clientName = clientName; } public void flights() { /* assume method is implemented */ }

public void hotels() { /* assume method is implemented */ }

public void excursions() { /* assume method is implemented */ }

public void phrases() { /* assume method is implemented */ }

}

Questions 31 - 34 refer to the following interface:

interface Qwerty{

public void qwertyA(); public void qwertyB(); public void qwertyC(); public void qwertyD(); public void qwertyE(); public void qwertyF(); public void qwertyG();

Exposure Java 2015, APCS Edition Chapter 13 Test Page 16 06-02-15

public void qwertyH(); }

31. The Qwerty interface contains 8 practical methods for various utility purposes.Your new program only requires only the use of method qwertyA.Which of the following concrete classes properly uses the Qwerty interface?

(A)class Q31 implements Qwerty{

public void qwertyA() { /* assume method qwertyA is implemented */ } public abstract void qwertyB() { } public abstract void qwertyC() { } public abstract void qwertyD() { } public abstract void qwertyE() { } public abstract void qwertyF() { } public abstract void qwertyG() { } public abstract void qwertyH() { }

}

(B)class Q31 implements Qwerty{

public void qwertyA() { /* assume method qwertyA is implemented */ } }

###(C)class Q31 implements Qwerty{

public void qwertyA() { /* assume method qwertyA is implemented */ } public void qwertyB() { } public void qwertyC() { } public void qwertyD() { } public void qwertyE() { } public void qwertyF() { } public void qwertyG() { } public void qwertyH() { }

}

(D)class Q31 extends Qwerty{

public void qwertyA() { /* assume method qwertyA is implemented */ } public void qwertyB() { } public void qwertyC() { } public void qwertyD() { } public void qwertyE() { } public void qwertyF() { } public void qwertyG() { } public void qwertyH() { }

}

32. The Qwerty methods need to be used frequently and the directly approach with a concrete classimplementing the interface is not very efficient. You decide to create an abstract class to simplifyusing just a few methods of the Qwerty interface.

Which of the following classes will satisfy that goal?

###(A)abstract class Qwerty2 implements Qwerty{

(B)abstract class Qwerty2 extends Qwerty{

Exposure Java 2015, APCS Edition Chapter 13 Test Page 17 06-02-15

public void qwertyA() { } public void qwertyB() { } public void qwertyC() { } public void qwertyD() { } public void qwertyE() { } public void qwertyF() { } public void qwertyG() { } public void qwertyH() { }

}

public void qwertyA() { } public void qwertyB() { } public void qwertyC() { } public void qwertyD() { } public void qwertyE() { } public void qwertyF() { } public void qwertyG() { } public void qwertyH() { }

}

(C)abstract class Qwerty2 implements Qwerty{

public abstract void qwertyA() { } public abstract void qwertyB() { } public abstract void qwertyC() { } public abstract void qwertyD() { } public abstract void qwertyE() { } public abstract void qwertyF() { } public abstract void qwertyG() { } public abstract void qwertyH() { }

}

(D)abstract class Qwerty2 extends Qwerty{

public abstract void qwertyA() { } public abstract void qwertyB() { } public abstract void qwertyC() { } public abstract void qwertyD() { } public abstract void qwertyE() { } public abstract void qwertyF() { } public abstract void qwertyG() { } public abstract void qwertyH() { }

}

33. The special abstract class that facilitates using an interfaces, when only a few methods are implementedis called a(n)

(A) abstract bridge class.### (B) adapter class

(C) concrete adapter class(D) empty class(E) empty abstract class

34. Assume that a proper abstract class in question 32 has been created to facility one or two methods.Which one of the following concrete classes, uses that abstract class correctly?

Which of the following classes will satisfy that goal?

(A)class Q31 implements Qwerty{

public void qwertyA()

###(B)class Q31 implements Qwerty{

public void qwertyA()Exposure Java 2015, APCS Edition Chapter 13 Test Page 18 06-02-15

{ /* assume method qwertyA is implemented */ } public abstract void qwertyB() { } public abstract void qwertyC() { } public abstract void qwertyD() { } public abstract void qwertyE() { } public abstract void qwertyF() { } public abstract void qwertyG() { } public abstract void qwertyH() { }

}

{ /* assume method qwertyA is implemented */ } }

(C)class Q31 implements Qwerty{

public void qwertyA() { /* assume method qwertyA is implemented */ } public void qwertyB() { } public void qwertyC() { } public void qwertyD() { } public void qwertyE() { } public void qwertyF() { } public void qwertyG() { } public void qwertyH() { }

}

(D)class Q31 extends Qwerty{

public void qwertyA() { /* assume method qwertyA is implemented */ } public void qwertyB() { } public void qwertyC() { } public void qwertyD() { } public void qwertyE() { } public void qwertyF() { } public void qwertyG() { } public void qwertyH() { }

}

Questions 35-36 refer to this interface declaration.

interface List<E>{

public int Size();// returns the number of elements in list

public boolean add(E obj);Exposure Java 2015, APCS Edition Chapter 13 Test Page 19 06-02-15

// appends obj to the end of list; returns true

public void add(int index, E obj);// inserts obj at position index (0 <= index <= size),// moving elements to the right (adds 1 to their indices) and adjusts size

public E get(int index);// returns element at position index

public E set(int index, E obj);// replaces the element at position index with obj// returns the element formerly at the specified position

public E remove(int index);// removes element from position index, moving elements// at position index+1 and higher to the left// (subtracts 1 from their indices) and adjusts size// returns the element formerly at the specified position

}

35. This interface declaration uses

(A) inheritance.

(B) composition.

(C) polymorphism.

### (D) generics.

(E) All of the above

36. The E used in the interface declaration is

I. a Java reserved word short for Element.II. a class variable for the data type that is shared by every instance of E.III. not a reserved word and every instance of E can be replaced by another identifier.

IV. an indication that this is a generic interface.

Exposure Java 2015, APCS Edition Chapter 13 Test Page 20 06-02-15

(A) III only

(B) IV only

(C) I and II only

### (D) III and IV only

(E) I, II, III and IV

37. Assume that Qwerty is a generic class in Java.What is true about the following statement:

Qwerty<String> q = new Qwerty<String>();

(A) It will compile and execute without problems.(B) It will not compile.(C) Object q will accept any data type.

### (D) Object q will only accept String objects.

38. Assume that Qwerty is a generic class in Java.What is true about the following statement:

Qwerty q = new Qwerty();

(A) It will compile and execute without problems.(B) It will not compile.

### (C) Object q will accept any data type.(D) Object q will only accept Qwerty objects.

39. Consider the following declaration.

ArrayList<ArrayList<String>> x = new ArrayList<ArrayList<String>>();

(A) It will cause a compile error.(B) It will create a runtime exception.

### (C) It declares x as an object that stores String ArrayList objects.(D) The declaration is correct, but very redundant.

Exposure Java 2015, APCS Edition Chapter 13 Test Page 21 06-02-15

40. What is the E in a class heading, like public class List<E> ?

(A) It stands for Element.(B) It is a class identifier that can be used with inheritance.(C) It is a class identifier that can be used with implementing an interface.

### (D) All of the above

Exposure Java 2015, APCS Edition Chapter 13 Test Page 22 06-02-15