You are on page 1of 22

Exposure Java Multiple Choice Test

Chapter Interfaces and Abstract classes


13

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.

(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: 3000 (B) Tom's checking balance: 3000
Tom's checking balance: 2000 Tom's checking balance: 4000
Tom's checking balance: 7000 Tom's checking balance: -1000

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

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


12. 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: 3000 (B) Tom's checking balance: 3000
Tom's checking balance: 2000 Tom's checking balance: 4000
Tom's checking balance: 7000 Tom's checking balance: -1000

(C) Tom's checking balance: 3000 (D) Tom's checking balance: 3000
Tom's checking balance: 4000 Tom's checking balance: 4000
Tom's checking balance: 9000 Tom'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);
}

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


13. 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; }
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

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


Questions 15-16 refer to this program:
public class Q1516
{
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; }
}

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


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

###
(A) Tom's checking balance: 4000 (C) Tom's checking balance: 6000
Tom's checking balance: 5000 Tom's checking balance: 9000
Tom's checking balance: 3000 Tom's checking balance: 5000

Tom's savings balance: 6000 Tom's savings balance: 4000


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

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

Tom's savings balance: 6000 Tom's savings balance: 4000


Tom's savings balance: 5000 Tom's savings balance: 3000
Tom's savings balance: 9000 Tom'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) (B)
public void transferToChecking(double amount) public void transferToChecking(double amount)
{ {
checking -= amount; checking += amount;
savings += amount; savings -= amount;
} }

(C)### (D)
public void transferToChecking(double amount) public void transferToChecking(double amount)
{ {
if (savings >= amount) if (savings > amount)
{ {
checking += amount; checking += amount;
savings -= amount; savings -= amount;
} }
else }
System.out.println("Insufficient Funds");
}

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


Questions 17-20 refer to this program:
public class Q1720
{
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;
}
}

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


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

### (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 interface
and the comment symbol (//) is removed from the MyBank constructor?

(A) Yes

### (B) No

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


21. Abstract classes

(A) require abstract methods only.


(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.

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


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.
(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; }
}

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


25. What is the output of this program?

(A) Tom's checking balance: 5000


Tom's checking balance: 7500
Tom's checking balance: 9000

(B) Tom's checking balance: 5000


Tom's checking balance: 9000
Tom's checking balance: 7500

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


Tom's checking balance: 7500
Tom's checking balance: 6000

(D) Tom's checking balance: 5000


Tom's checking balance: 6000
Tom's checking balance: 7500

26. What would be the result of changing the keyword extends to implements in the definition
of 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 classes
II. interfaces
III. abstract classes

(A) I only
(B) II only
(C) III only
### (D) II and III only
(E) I, II and III

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


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 flights
Purchase train tickets
Get documentation ready, like passports and visas
Exchange dollars into local currency
Reserve hotels
Book excursions at different sites of interest
Learns 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) (B)
interface Europe abstract interface Europe
{ {
public void flights(); public abstract String clientName = "Smith";
public void railpass(); public abstract void flights();
public void documentation(); public abstract void railpass();
public void money(); public abstract void documentation();
public void hotels(); public abstract void money();
public void excursions(); public abstract void hotels();
public void phrases(); public abstract void excursions();
} public abstract void phrases();
}

(C) (D)
interface Europe interface Europe
{ {
public String clientName; public Travel() { }

public void flights(); public void flights();


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

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


29. A concrete class can be created for each foreign country. At the same time much work can be avoided
by 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 class
between 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.)

(A) (B)
abstract class WestEurope implements Europe class WestEurope implements Europe
{ {
public abstract void railpass() public void railpass()
{ /* assume method is implemented */ } { /* assume method is implemented */ }

public abstract void documentation() public void documentation()


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

public abstract void money() public void money()


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

(C) ###(D)
class WestEurope implements Europe abstract class WestEurope implements Europe
{ {
public void railpass() public void railpass()
{ /* assume method is implemented */ } { /* assume method is implemented */ }

public void documentation() public void documentation()


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

public void money() public void money()


{ /* assume method is implemented */ } { /* assume method is implemented */ }
}
public abstract void flights();
public abstract void hotels();
public abstract void excursions();
public abstract void phrases();
}

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


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 concrete
class will be shown here.

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

###(A) (B)
class Italy extends WestEurope class Italy extends WestEurope
{ {
private String clientName; private String clientName;

public Italy (String clientName) public Italy (String clientName)


{ {
this.clientName = clientName; clientName = clientName;
} }

public void flights() public void flights()


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

public void hotels() public void hotels()


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

public void excursions() public void excursions()


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

public void phrases() public void phrases()


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

(C) (D)
class Italy implements WestEurope class Italy
{ {
private String clientName; private String clientName;

public Italy (String clientName) public Italy (String clientName)


{ {
this.clientName = clientName; this.clientName = clientName;
} }

public void flights() public void flights()


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

public void hotels() public void hotels()


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

public void excursions() public void excursions()


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

public void phrases() public void phrases()


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

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


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();
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) (B)
class Q31 implements Qwerty class Q31 implements Qwerty
{ {
public void qwertyA() public void qwertyA()
{ {
/* assume method qwertyA is implemented */ /* 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() { }
}

###(C) (D)
class Q31 implements Qwerty class Q31 extends Qwerty
{ {
public void qwertyA() public void qwertyA()
{ {
/* assume method qwertyA is implemented */ /* assume method qwertyA is implemented */
} }

public void qwertyB() { } public void qwertyB() { }


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

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


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

Which of the following classes will satisfy that goal?

###(A) (B)
abstract class Qwerty2 implements Qwerty abstract class Qwerty2 extends Qwerty
{ {
public void qwertyA() { } public void qwertyA() { }
public void qwertyB() { } public void qwertyB() { }
public void qwertyC() { } public void qwertyC() { }
public void qwertyD() { } public void qwertyD() { }
public void qwertyE() { } public void qwertyE() { }
public void qwertyF() { } public void qwertyF() { }
public void qwertyG() { } public void qwertyG() { }
public void qwertyH() { } public void qwertyH() { }
} }

(C) (D)
abstract class Qwerty2 implements Qwerty abstract class Qwerty2 extends Qwerty
{ {
public abstract void qwertyA() { } public abstract void qwertyA() { }
public abstract void qwertyB() { } public abstract void qwertyB() { }
public abstract void qwertyC() { } public abstract void qwertyC() { }
public abstract void qwertyD() { } public abstract void qwertyD() { }
public abstract void qwertyE() { } public abstract void qwertyE() { }
public abstract void qwertyF() { } public abstract void qwertyF() { }
public abstract void qwertyG() { } public abstract void qwertyG() { }
public abstract void qwertyH() { } public abstract void qwertyH() { }
} }

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

(A) abstract bridge class.


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

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


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) ###(B)
class Q31 implements Qwerty class Q31 implements Qwerty
{ {
public void qwertyA() public void qwertyA()
{ {
/* assume method qwertyA is implemented */ /* 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() { }
}

(C) (D)
class Q31 implements Qwerty class Q31 extends Qwerty
{ {
public void qwertyA() public void qwertyA()
{ {
/* assume method qwertyA is implemented */ /* assume method qwertyA is implemented */
} }

public void qwertyB() { } public void qwertyB() { }


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

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


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);


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

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


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.

(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.

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


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.

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

You might also like