Search Header Logo

APCSA Diag

Authored by Johnson Ting

Computers

9th - 12th Grade

Used 4+ times

APCSA Diag
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

40 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Consider this inheritance hierarchy, in which Novel and Textbook are subclasses of Book. Which of the following is a false statement about the classes shown?

 

The Textbook class can have private instance variables that are in neither Book nor Novel.

Each of the classes—Book, Novel, and Textbook—can have a method computeShelfLife, whose code in Book and Novel is identical, but different from the code in Textbook.

If the Book class has private instance variables title and author, then Novel and Textbook cannot directly access them.

Both Novel and Textbook inherit the constructors in Book.

If the Book class has a private method called readFile, this method may not be accessed in either the Novel or Textbook classes.

2.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

A programmer is designing a program to catalog all books in a library. He plans to have a Book class that stores features of each book: author, title, isOnShelf, and so on, with operations like getAuthor, getTitle, getShelfInfo, and setShelfInfo. Another class, LibraryList, will store an array of Book objects. The LibraryList class will include operations such as listAllBooks, addBook, removeBook, and searchForBook. The programmer plans to implement and test the Book class first, before implementing the LibraryList class. The programmer’s plan to write the Book class first is an example of

top-down development.

bottom-up development.

procedural abstraction.

information hiding

a driver program.

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

The color of a pixel can be represented using the RGB (Red, Green, Blue) color

model, which stores values for red, green, and blue, each ranging from 0 to 255.

How many bits (binary digits) would be needed to represent a color in the RGB

model?

8

16

24

32

40

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Which of the following represents correct /* implementation */ code for the constructor

in the Card class?

suit = cardSuit;

value = cardValue;

cardSuit = suit;

cardValue = value;

Card = new Card(suit, value);

Card = new Card(cardSuit, cardValue);

suit = getSuit();

value = getValue();

5.

MULTIPLE SELECT QUESTION

2 mins • 1 pt

Media Image

Consider the implementation of a writeDeck method that is added to the Deck

class.

/** Write the cards in deck, one per line. */

public void writeDeck()

{

/* implementation code */

}

Which of the following is correct /* implementation code */?

System.out.println(deck);

for (Card card : deck)

System.out.println(card);

for (Card card : deck)

System.out.println((String) card);

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Refer to the following method that finds the smallest value in an array.

Which replacement(s) for /* some value */ will always result in correct execution

of the findMin method?

I only

II only

III only

I and III only

II and III only

7.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Consider the following loop, where n is some positive integer.

for (int i = 0; i < n; i += 2)

{

if (/* test */)

/* perform some action */

}

In terms of n, which Java expression represents the maximum number of times

that /* perform some action */ could be executed?

n / 2

(n + 1) / 2

n

(n - 1)

(n - 1) / 2

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?