Chaper 5 Codes Flashcards

1
Q

What is the purpose of the SnakeEyes class?

A

Demonstrates the use of a programmer-defined class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In the SnakeEyes class, how many times are the dice rolled?

A

500

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are snake eyes in the context of the SnakeEyes class?

A

Rolling two ones on the dice

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the Die class represent?

A

One die with faces showing values between 1 and 6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the maximum face value of the Die class?

A

6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What method in the Die class computes a new face value?

A

roll()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the SloganCounter class demonstrate?

A

The use of the static modifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How many Slogan objects were created in the SloganCounter class?

A

5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the Slogan class?

A

Represents a single slogan or motto

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What static variable in the Slogan class counts the instances created?

A

count

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the output of the SloganCounter class after creating slogans?

A

Slogans created: 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What concept does the PigLatin class demonstrate?

A

Method decomposition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What happens in the PigLatin class when ‘translate another sentence’ is prompted?

A

It allows the user to translate additional sentences into Pig Latin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the PigLatinTranslator class do?

A

Translates a sentence of words into Pig Latin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What suffix is appended to words in Pig Latin that begin with a vowel?

A

yay

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What method determines if a word begins with a vowel?

A

beginsWithVowel()

17
Q

What is the output when translating ‘Do you speak Pig Latin’ into Pig Latin?

A

oday ouyay eakspay igpay atinlay

18
Q

What does the ParameterTester class demonstrate?

A

The effects of passing various types of parameters

19
Q

What types of parameters are tested in the ParameterTester class?

A

One primitive and two objects

20
Q

What is the purpose of the changeValues method in the ParameterModifier class?

A

Modifies the parameters and prints their values before and after

21
Q

What happens to the primitive type parameter in the changeValues method?

A

It does not retain changes after the method call

22
Q

What happens to the object type parameters in the changeValues method?

A

They can be modified and retain changes after the method call

23
Q

What is a key feature of method overloading demonstrated in the Overload class?

A

Multiple methods with the same name but different parameters

24
Q

What is the output of the getAverage method for two doubles?

A

Average of the two double values

25
What does the getAverage method return when called with two characters?
The average character based on their ASCII values
26
Fill in the blank: The _______ class represents a single integer as an object.
Num
27
What is the initial value set for the Num object?
Value passed during the constructor
28
What does the toString method in the Num class return?
The stored integer value as a string
29
True or False: The Slogan class has a static method to get the count of instances created.
True